From 870da4a100bedf1c21e43d6ab708de5c6a023c94 Mon Sep 17 00:00:00 2001 From: Abyss777 Date: Thu, 4 Aug 2016 10:45:26 +0500 Subject: Fix NullPointer exception without 'mail.smtp.username' in config. --- src/org/traccar/notification/NotificationMail.java | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/src/org/traccar/notification/NotificationMail.java b/src/org/traccar/notification/NotificationMail.java index a0b80d2ab..f9d42968f 100644 --- a/src/org/traccar/notification/NotificationMail.java +++ b/src/org/traccar/notification/NotificationMail.java @@ -55,9 +55,19 @@ public final class NotificationMail { 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; } -- cgit v1.2.3