aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/org/traccar/database
diff options
context:
space:
mode:
authorAnton Tananaev <anton@traccar.org>2022-07-12 20:13:45 -0700
committerAnton Tananaev <anton@traccar.org>2022-07-12 20:13:45 -0700
commita1ec223a7ee9ff86a881428f787c6f11d532432a (patch)
tree4a43d4e3b91ff7444deef13f2f2a80ef6e6f8050 /src/main/java/org/traccar/database
parent493ff1068ea3e4d96f2475234b265b47cce8691f (diff)
downloadtrackermap-server-a1ec223a7ee9ff86a881428f787c6f11d532432a.tar.gz
trackermap-server-a1ec223a7ee9ff86a881428f787c6f11d532432a.tar.bz2
trackermap-server-a1ec223a7ee9ff86a881428f787c6f11d532432a.zip
Support from email name (fix #4887)
Diffstat (limited to 'src/main/java/org/traccar/database')
-rw-r--r--src/main/java/org/traccar/database/MailManager.java16
1 files changed, 15 insertions, 1 deletions
diff --git a/src/main/java/org/traccar/database/MailManager.java b/src/main/java/org/traccar/database/MailManager.java
index 0c868e1fc..72b8b72c1 100644
--- a/src/main/java/org/traccar/database/MailManager.java
+++ b/src/main/java/org/traccar/database/MailManager.java
@@ -31,6 +31,7 @@ import javax.mail.internet.InternetAddress;
import javax.mail.internet.MimeBodyPart;
import javax.mail.internet.MimeMessage;
import javax.mail.internet.MimeMultipart;
+import java.io.UnsupportedEncodingException;
import java.util.Date;
import java.util.Properties;
@@ -88,6 +89,10 @@ public final class MailManager {
if (from != null) {
properties.put("mail.smtp.from", from);
}
+ String fromName = provider.getString("mail.smtp.fromName");
+ if (fromName != null) {
+ properties.put("mail.smtp.fromName", fromName);
+ }
}
return properties;
}
@@ -120,7 +125,16 @@ public final class MailManager {
String from = properties.getProperty("mail.smtp.from");
if (from != null) {
- message.setFrom(new InternetAddress(from));
+ String fromName = properties.getProperty("mail.smtp.fromName");
+ if (fromName != null) {
+ try {
+ message.setFrom(new InternetAddress(from, fromName));
+ } catch (UnsupportedEncodingException e) {
+ throw new MessagingException("Email address issue");
+ }
+ } else {
+ message.setFrom(new InternetAddress(from));
+ }
}
message.addRecipient(Message.RecipientType.TO, new InternetAddress(user.getEmail()));