diff options
author | ninioe <ninioe@gmail.com> | 2016-08-04 09:51:40 +0300 |
---|---|---|
committer | ninioe <ninioe@gmail.com> | 2016-08-04 09:51:40 +0300 |
commit | b2613805e5de4b7d3755b063ad76d737e713616f (patch) | |
tree | 726c0c6effdeced9903b6b26ef0480047d2d179c /src/org/traccar/notification/NotificationMail.java | |
parent | 6f32f4a9460ff3be2823d7a133659d29bf057237 (diff) | |
parent | 41668cae9763a523c775a8a998620fe286176c9e (diff) | |
download | trackermap-server-b2613805e5de4b7d3755b063ad76d737e713616f.tar.gz trackermap-server-b2613805e5de4b7d3755b063ad76d737e713616f.tar.bz2 trackermap-server-b2613805e5de4b7d3755b063ad76d737e713616f.zip |
Merge remote-tracking branch 'refs/remotes/tananaev/master'
Diffstat (limited to 'src/org/traccar/notification/NotificationMail.java')
-rw-r--r-- | src/org/traccar/notification/NotificationMail.java | 37 |
1 files changed, 21 insertions, 16 deletions
diff --git a/src/org/traccar/notification/NotificationMail.java b/src/org/traccar/notification/NotificationMail.java index 944200f2f..f9d42968f 100644 --- a/src/org/traccar/notification/NotificationMail.java +++ b/src/org/traccar/notification/NotificationMail.java @@ -48,19 +48,26 @@ public final class NotificationMail { result.put("mail.smtp.port", config.getString("mail.smtp.port", "25")); if (config.getBoolean("mail.smtp.starttls.enable")) { - result.put("mail.smtp.starttls.enable", - config.getBoolean("mail.smtp.starttls.enable")); + result.put("mail.smtp.starttls.enable", config.getBoolean("mail.smtp.starttls.enable")); } else if (config.getBoolean("mail.smtp.ssl.enable")) { - result.put("mail.smtp.socketFactory.port", - result.getProperty("mail.smtp.port")); - result.put("mail.smtp.socketFactory.class", - "javax.net.ssl.SSLSocketFactory"); + result.put("mail.smtp.ssl.enable", config.getBoolean("mail.smtp.ssl.enable")); } + result.put("mail.smtp.ssl.trust", config.getBoolean("mail.smtp.ssl.trust")); result.put("mail.smtp.auth", config.getBoolean("mail.smtp.auth")); - result.put("mail.smtp.user", config.getString("mail.smtp.username", null)); - result.put("mail.smtp.password", config.getString("mail.smtp.password", null)); - result.put("mail.smtp.from", config.getString("mail.smtp.from", null)); + + String username = config.getString("mail.smtp.username"); + if (username != null) { + result.put("mail.smtp.user", username); + } + String password = config.getString("mail.smtp.password"); + if (password != null) { + result.put("mail.smtp.password", password); + } + String from = config.getString("mail.smtp.from"); + if (from != null) { + result.put("mail.smtp.from", from); + } } return result; } @@ -77,12 +84,10 @@ public final class NotificationMail { result.put("mail.smtp.starttls.enable", tls); } else if (object.getAttributes().containsKey("mail.smtp.ssl.enable")) { boolean ssl = Boolean.parseBoolean((String) object.getAttributes().get("mail.smtp.ssl.enable")); - if (ssl) { - result.put("mail.smtp.socketFactory.port", - result.getProperty("mail.smtp.port")); - result.put("mail.smtp.socketFactory.class", - "javax.net.ssl.SSLSocketFactory"); - } + result.put("mail.smtp.ssl.enable", ssl); + } + if (object.getAttributes().containsKey("mail.smtp.ssl.trust")) { + result.put("mail.smtp.ssl.trust", object.getAttributes().get("mail.smtp.ssl.trust")); } boolean auth = Boolean.parseBoolean((String) object.getAttributes().get("mail.smtp.auth")); result.put("mail.smtp.auth", auth); @@ -117,7 +122,7 @@ public final class NotificationMail { return; } } - mailSession = Session.getDefaultInstance(mailServerProperties, null); + mailSession = Session.getInstance(mailServerProperties, null); mailMessage = new MimeMessage(mailSession); |