aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/org/traccar/mail
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/org/traccar/mail')
-rw-r--r--src/main/java/org/traccar/mail/LogMailManager.java10
-rw-r--r--src/main/java/org/traccar/mail/MailManager.java8
-rw-r--r--src/main/java/org/traccar/mail/SmtpMailManager.java10
3 files changed, 17 insertions, 11 deletions
diff --git a/src/main/java/org/traccar/mail/LogMailManager.java b/src/main/java/org/traccar/mail/LogMailManager.java
index 4af68809c..5c7572b0c 100644
--- a/src/main/java/org/traccar/mail/LogMailManager.java
+++ b/src/main/java/org/traccar/mail/LogMailManager.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2022 Anton Tananaev (anton@traccar.org)
+ * Copyright 2022 - 2023 Anton Tananaev (anton@traccar.org)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -32,12 +32,14 @@ public class LogMailManager implements MailManager {
}
@Override
- public void sendMessage(User user, String subject, String body) throws MessagingException {
- sendMessage(user, subject, body, null);
+ public void sendMessage(
+ User user, boolean system, String subject, String body) throws MessagingException {
+ sendMessage(user, system, subject, body, null);
}
@Override
- public void sendMessage(User user, String subject, String body, MimeBodyPart attachment) throws MessagingException {
+ public void sendMessage(
+ User user, boolean system, String subject, String body, MimeBodyPart attachment) throws MessagingException {
LOGGER.info(
"Email sent\nTo: {}\nSubject: {}\nAttachment: {}\nBody:\n{}",
user.getEmail(), subject, attachment != null ? attachment.getFileName() : null, body);
diff --git a/src/main/java/org/traccar/mail/MailManager.java b/src/main/java/org/traccar/mail/MailManager.java
index 69efbed32..3547fd37e 100644
--- a/src/main/java/org/traccar/mail/MailManager.java
+++ b/src/main/java/org/traccar/mail/MailManager.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2022 Anton Tananaev (anton@traccar.org)
+ * Copyright 2022 - 2023 Anton Tananaev (anton@traccar.org)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -24,8 +24,10 @@ public interface MailManager {
boolean getEmailEnabled();
- void sendMessage(User user, String subject, String body) throws MessagingException;
+ void sendMessage(
+ User user, boolean system, String subject, String body) throws MessagingException;
- void sendMessage(User user, String subject, String body, MimeBodyPart attachment) throws MessagingException;
+ void sendMessage(
+ User user, boolean system, String subject, String body, MimeBodyPart attachment) throws MessagingException;
}
diff --git a/src/main/java/org/traccar/mail/SmtpMailManager.java b/src/main/java/org/traccar/mail/SmtpMailManager.java
index 4a0b7048f..8d1afbd3e 100644
--- a/src/main/java/org/traccar/mail/SmtpMailManager.java
+++ b/src/main/java/org/traccar/mail/SmtpMailManager.java
@@ -93,19 +93,21 @@ public final class SmtpMailManager implements MailManager {
return config.hasKey(Keys.MAIL_SMTP_HOST);
}
+ @Override
public void sendMessage(
- User user, String subject, String body) throws MessagingException {
- sendMessage(user, subject, body, null);
+ User user, boolean system, String subject, String body) throws MessagingException {
+ sendMessage(user, system, subject, body, null);
}
+ @Override
public void sendMessage(
- User user, String subject, String body, MimeBodyPart attachment) throws MessagingException {
+ User user, boolean system, String subject, String body, MimeBodyPart attachment) throws MessagingException {
Properties properties = null;
if (!config.getBoolean(Keys.MAIL_SMTP_IGNORE_USER_CONFIG)) {
properties = getProperties(new PropertiesProvider(user));
}
- if (properties == null) {
+ if (properties == null && (system || !config.getBoolean(Keys.MAIL_SMTP_SYSTEM_ONLY))) {
properties = getProperties(new PropertiesProvider(config));
}
if (properties == null) {