Browse Source

[Fix-5032][Alert]Support email multiple format (#5033)

* support multilple email format

Co-authored-by: 李巨丰 <lijf@2345.com>
pull/3/MERGE
JuFeng Li 3 years ago committed by GitHub
parent
commit
3769066803
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 11
      dolphinscheduler-alert-plugin/dolphinscheduler-alert-email/src/main/java/org/apache/dolphinscheduler/plugin/alert/email/MailSender.java

11
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);

Loading…
Cancel
Save