Commit 7511204c authored by Quxl's avatar Quxl

x

parent 2a4c0189
......@@ -77,12 +77,16 @@ public class MailUtil {
}
}
public static void sendBySmtps(String host, Integer port, boolean is_auth, final String username, final String password, final String from, String subject, String content, File[] attachments, String... emailTo) {
public static void sendBySmtps(String host, Integer port, final String username, final String password, final String from, String subject, String content, File[] attachments, String... emailTo) {
boolean is_auth = StringUtil.isNotBlank(username) && StringUtil.isNotBlank(password);
Properties properties = new Properties();
properties.put("mail.transport.protocol", "smtps");
properties.put("mail.smtp.auth", is_auth ? "true" : "false");
properties.put("mail.smtp.host", host);
properties.put("mail.smtp.port", port);
properties.setProperty("mail.transport.protocol", "smtps");
properties.setProperty("mail.smtp.auth", is_auth ? "true" : "false");
properties.setProperty("mail.smtp.host", String.valueOf(host));
properties.setProperty("mail.smtp.port", String.valueOf(port));
properties.setProperty("mail.smtp.socketFactory.port", String.valueOf(port));
properties.setProperty("mail.smtp.socketFactory.class", "javax.net.ssl.SSLSocketFactory");
properties.setProperty("mail.smtp.socketFactory.fallback", "false");
try {
Session session = is_auth ? Session.getDefaultInstance(properties, new Authenticator() {
protected PasswordAuthentication getPasswordAuthentication() {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment