mirror of
https://gitee.com/dolphinscheduler/DolphinScheduler.git
synced 2024-12-02 20:28:03 +08:00
mail support ssl and install.sh update
This commit is contained in:
parent
ec3c0f26db
commit
df0083224d
@ -59,6 +59,8 @@ public class Constants {
|
||||
|
||||
public static final String MAIL_SMTP_STARTTLS_ENABLE = "mail.smtp.starttls.enable";
|
||||
|
||||
public static final String MAIL_SMTP_SSL_ENABLE = "mail.smtp.ssl.enable";
|
||||
|
||||
public static final String TEXT_HTML_CHARSET_UTF_8 = "text/html;charset=utf-8";
|
||||
|
||||
public static final String STRING_TRUE = "true";
|
||||
|
@ -33,6 +33,7 @@ import org.springframework.util.ResourceUtils;
|
||||
import javax.mail.*;
|
||||
import javax.mail.internet.*;
|
||||
import java.io.*;
|
||||
import java.security.Security;
|
||||
import java.util.*;
|
||||
|
||||
import static cn.escheduler.alert.utils.PropertyUtils.getInt;
|
||||
@ -58,6 +59,10 @@ public class MailUtils {
|
||||
|
||||
public static final String xlsFilePath = getString(Constants.XLS_FILE_PATH);
|
||||
|
||||
public static final String starttlsEnable = getString(Constants.MAIL_SMTP_STARTTLS_ENABLE);
|
||||
|
||||
public static final String sslEnable = getString(Constants.MAIL_SMTP_SSL_ENABLE);
|
||||
|
||||
private static Template MAIL_TEMPLATE;
|
||||
|
||||
static {
|
||||
@ -122,7 +127,10 @@ public class MailUtils {
|
||||
//set charset
|
||||
email.setCharset(Constants.UTF_8);
|
||||
// TLS verification
|
||||
email.setTLS(true);
|
||||
email.setTLS(Boolean.valueOf(starttlsEnable));
|
||||
|
||||
// SSL verification
|
||||
email.setSSL(Boolean.valueOf(sslEnable));
|
||||
if (CollectionUtils.isNotEmpty(receivers)){
|
||||
// receivers mail
|
||||
for (String receiver : receivers) {
|
||||
@ -269,11 +277,15 @@ public class MailUtils {
|
||||
* @throws MessagingException
|
||||
*/
|
||||
private static MimeMessage getMimeMessage(Collection<String> receivers) throws MessagingException {
|
||||
// Security.addProvider(new com.sun.net.ssl.internal.ssl.Provider());
|
||||
// final String SSL_FACTORY = "javax.net.ssl.SSLSocketFactory";
|
||||
|
||||
Properties props = new Properties();
|
||||
props.setProperty(Constants.MAIL_HOST, mailServerHost);
|
||||
props.setProperty(Constants.MAIL_SMTP_AUTH, Constants.STRING_TRUE);
|
||||
props.setProperty(Constants.MAIL_TRANSPORT_PROTOCOL, mailProtocol);
|
||||
props.setProperty(Constants.MAIL_SMTP_STARTTLS_ENABLE, Constants.STRING_TRUE);
|
||||
props.setProperty(Constants.MAIL_SMTP_STARTTLS_ENABLE, starttlsEnable);
|
||||
props.setProperty("mail.smtp.ssl.enable", sslEnable);
|
||||
Authenticator auth = new Authenticator() {
|
||||
@Override
|
||||
protected PasswordAuthentication getPasswordAuthentication() {
|
||||
|
@ -8,6 +8,11 @@ mail.server.port=25
|
||||
mail.sender=xxxxxxx
|
||||
mail.passwd=xxxxxxx
|
||||
|
||||
# TLS
|
||||
mail.smtp.starttls.enable=false
|
||||
# SSL
|
||||
mail.smtp.ssl.enable=true
|
||||
|
||||
#xls file path,need create if not exist
|
||||
xls.file.path=/tmp/xls
|
||||
|
||||
|
@ -96,6 +96,13 @@ mailSender="xxxxxxxxxx"
|
||||
# 发送人密码
|
||||
mailPassword="xxxxxxxxxx"
|
||||
|
||||
# TLS邮件协议支持
|
||||
starttlsEnable="false"
|
||||
|
||||
# SSL邮件协议支持
|
||||
# 注意:默认开启的是SSL协议,TLS和SSL只能有一个处于true状态
|
||||
sslEnable="true"
|
||||
|
||||
# 下载Excel路径
|
||||
xlsFilePath="/tmp/xls"
|
||||
|
||||
@ -307,6 +314,8 @@ sed -i ${txt} "s#mail.server.host.*#mail.server.host=${mailServerHost}#g" conf/a
|
||||
sed -i ${txt} "s#mail.server.port.*#mail.server.port=${mailServerPort}#g" conf/alert.properties
|
||||
sed -i ${txt} "s#mail.sender.*#mail.sender=${mailSender}#g" conf/alert.properties
|
||||
sed -i ${txt} "s#mail.passwd.*#mail.passwd=${mailPassword}#g" conf/alert.properties
|
||||
sed -i ${txt} "s#mail.smtp.starttls.enable.*#mail.smtp.starttls.enable=${starttlsEnable}#g" conf/alert.properties
|
||||
sed -i ${txt} "s#mail.smtp.ssl.enable.*#mail.smtp.ssl.enable=${sslEnable}#g" conf/alert.properties
|
||||
sed -i ${txt} "s#xls.file.path.*#xls.file.path=${xlsFilePath}#g" conf/alert.properties
|
||||
|
||||
|
||||
|
@ -426,7 +426,7 @@ CREATE TABLE `t_escheduler_worker_server` (
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
||||
|
||||
-- Records of t_escheduler_user,user : admin , password : escheduler123
|
||||
INSERT INTO `t_escheduler_user` VALUES ('1', 'admin', '055a97b5fcd6d120372ad1976518f371', '0', '825193156@qq.com', '15001335629', '0', '2018-03-27 15:48:50', '2018-10-24 17:40:22');
|
||||
INSERT INTO `t_escheduler_user` VALUES ('1', 'admin', '055a97b5fcd6d120372ad1976518f371', '0', 'xxx@qq.com', 'xxxx', '0', '2018-03-27 15:48:50', '2018-10-24 17:40:22');
|
||||
INSERT INTO `t_escheduler_alertgroup` VALUES (1, 'escheduler管理员告警组', '0', 'escheduler管理员告警组','2018-11-29 10:20:39', '2018-11-29 10:20:39');
|
||||
INSERT INTO `t_escheduler_relation_user_alertgroup` VALUES ('1', '1', '1', '2018-11-29 10:22:33', '2018-11-29 10:22:33');
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user