You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@dolphinscheduler.apache.org by ki...@apache.org on 2021/03/11 03:35:33 UTC
[incubator-dolphinscheduler] branch dev updated:
[Fix-5032][Alert]Support email multiple format (#5033)
This is an automated email from the ASF dual-hosted git repository.
kirs pushed a commit to branch dev
in repository https://gitbox.apache.org/repos/asf/incubator-dolphinscheduler.git
The following commit(s) were added to refs/heads/dev by this push:
new 3769066 [Fix-5032][Alert]Support email multiple format (#5033)
3769066 is described below
commit 3769066803803e7f97b1083eff12b1d6f8486771
Author: JuFeng Li <92...@qq.com>
AuthorDate: Thu Mar 11 11:35:25 2021 +0800
[Fix-5032][Alert]Support email multiple format (#5033)
* support multilple email format
Co-authored-by: 李巨丰 <li...@2345.com>
---
.../dolphinscheduler/plugin/alert/email/MailSender.java | 11 +++++++++++
1 file changed, 11 insertions(+)
diff --git a/dolphinscheduler-alert-plugin/dolphinscheduler-alert-email/src/main/java/org/apache/dolphinscheduler/plugin/alert/email/MailSender.java b/dolphinscheduler-alert-plugin/dolphinscheduler-alert-email/src/main/java/org/apache/dolphinscheduler/plugin/alert/email/MailSender.java
index 192578f..0540b6c 100644
--- a/dolphinscheduler-alert-plugin/dolphinscheduler-alert-email/src/main/java/org/apache/dolphinscheduler/plugin/alert/email/MailSender.java
+++ b/dolphinscheduler-alert-plugin/dolphinscheduler-alert-email/src/main/java/org/apache/dolphinscheduler/plugin/alert/email/MailSender.java
@@ -39,6 +39,8 @@ import java.util.List;
import java.util.Map;
import java.util.Properties;
+import javax.activation.CommandMap;
+import javax.activation.MailcapCommandMap;
import javax.mail.Authenticator;
import javax.mail.Message;
import javax.mail.MessagingException;
@@ -284,6 +286,15 @@ public class MailSender {
* @return the new Session
*/
private Session getSession() {
+ // support multilple email format
+ MailcapCommandMap mc = (MailcapCommandMap) CommandMap.getDefaultCommandMap();
+ mc.addMailcap("text/html;; x-java-content-handler=com.sun.mail.handlers.text_html");
+ mc.addMailcap("text/xml;; x-java-content-handler=com.sun.mail.handlers.text_xml");
+ mc.addMailcap("text/plain;; x-java-content-handler=com.sun.mail.handlers.text_plain");
+ mc.addMailcap("multipart/*;; x-java-content-handler=com.sun.mail.handlers.multipart_mixed");
+ mc.addMailcap("message/rfc822;; x-java-content-handler=com.sun.mail.handlers.message_rfc822");
+ CommandMap.setDefaultCommandMap(mc);
+
Properties props = new Properties();
props.setProperty(MailParamsConstants.MAIL_SMTP_HOST, mailSmtpHost);
props.setProperty(MailParamsConstants.MAIL_SMTP_PORT, mailSmtpPort);