mirror of
https://github.com/Athou/commafeed.git
synced 2026-03-21 21:37:29 +00:00
configurable "from" address (fix #664)
This commit is contained in:
@@ -89,6 +89,8 @@ public class CommaFeedConfiguration extends Configuration {
|
||||
|
||||
private String smtpPassword;
|
||||
|
||||
private String smtpFromAddress;
|
||||
|
||||
@NotNull
|
||||
private boolean heavyLoad;
|
||||
|
||||
|
||||
@@ -17,6 +17,7 @@ import lombok.RequiredArgsConstructor;
|
||||
import com.commafeed.CommaFeedConfiguration;
|
||||
import com.commafeed.CommaFeedConfiguration.ApplicationSettings;
|
||||
import com.commafeed.backend.model.User;
|
||||
import com.google.common.base.Optional;
|
||||
|
||||
/**
|
||||
* Mailing service
|
||||
@@ -34,6 +35,7 @@ public class MailService {
|
||||
|
||||
final String username = settings.getSmtpUserName();
|
||||
final String password = settings.getSmtpPassword();
|
||||
final String fromAddress = Optional.fromNullable(settings.getSmtpFromAddress()).or(settings.getSmtpUserName());
|
||||
|
||||
String dest = user.getEmail();
|
||||
|
||||
@@ -51,7 +53,7 @@ public class MailService {
|
||||
});
|
||||
|
||||
Message message = new MimeMessage(session);
|
||||
message.setFrom(new InternetAddress(username, "CommaFeed"));
|
||||
message.setFrom(new InternetAddress(fromAddress, "CommaFeed"));
|
||||
message.setRecipients(Message.RecipientType.TO, InternetAddress.parse(dest));
|
||||
message.setSubject("CommaFeed - " + subject);
|
||||
message.setContent(content, "text/html; charset=utf-8");
|
||||
|
||||
Reference in New Issue
Block a user