aboutsummaryrefslogtreecommitdiff
path: root/src/org/traccar/notification/NotificationMail.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/org/traccar/notification/NotificationMail.java')
-rw-r--r--src/org/traccar/notification/NotificationMail.java19
1 files changed, 10 insertions, 9 deletions
diff --git a/src/org/traccar/notification/NotificationMail.java b/src/org/traccar/notification/NotificationMail.java
index 115b109e6..8707b10da 100644
--- a/src/org/traccar/notification/NotificationMail.java
+++ b/src/org/traccar/notification/NotificationMail.java
@@ -43,7 +43,7 @@ public final class NotificationMail {
if (host != null) {
properties.put("mail.transport.protocol", provider.getString("mail.transport.protocol", "smtp"));
properties.put("mail.smtp.host", host);
- properties.put("mail.smtp.port", provider.getString("mail.smtp.port", "25"));
+ properties.put("mail.smtp.port", String.valueOf(provider.getInteger("mail.smtp.port", 25)));
String starttlsEnable = provider.getString("mail.smtp.starttls.enable");
if (starttlsEnable != null) {
@@ -68,8 +68,6 @@ public final class NotificationMail {
properties.put("mail.smtp.ssl.protocols", sslProtocols);
}
- properties.put("mail.smtp.auth", provider.getString("mail.smtp.auth"));
-
String username = provider.getString("mail.smtp.username");
if (username != null) {
properties.put("mail.smtp.username", username);
@@ -89,13 +87,16 @@ public final class NotificationMail {
public static void sendMailSync(long userId, Event event, Position position) throws MessagingException {
User user = Context.getPermissionsManager().getUser(userId);
- Properties properties = getProperties(new PropertiesProvider(Context.getConfig()));
- if (!properties.containsKey("mail.smtp.host")) {
+ Properties properties = null;
+ if (!Context.getConfig().getBoolean("mail.smtp.ignoreUserConfig")) {
properties = getProperties(new PropertiesProvider(user));
- if (!properties.containsKey("mail.smtp.host")) {
- Log.warning("No SMTP configuration found");
- return;
- }
+ }
+ if (properties == null || !properties.containsKey("mail.smtp.host")) {
+ properties = getProperties(new PropertiesProvider(Context.getConfig()));
+ }
+ if (!properties.containsKey("mail.smtp.host")) {
+ Log.warning("No SMTP configuration found");
+ return;
}
Session session = Session.getInstance(properties);