Skip to content

Commit

Permalink
EN-16521: Set a default from address if SMTP username is empty (#176)
Browse files Browse the repository at this point in the history
  • Loading branch information
urmilan authored May 30, 2017
1 parent 578c70e commit 298160a
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/main/java/com/socrata/datasync/SMTPMailer.java
Original file line number Diff line number Diff line change
Expand Up @@ -91,10 +91,16 @@ to true (the default), causes the transport to wait for the response to the QUIT
// -- Create a new message --
final MimeMessage msg = new MimeMessage(session);

// -- Set the FROM and TO fields --
// -- Set the FROM field --
String sender;
if (userPrefs.getSmtpUsername() != null && !userPrefs.getSmtpUsername().isEmpty()) {
msg.setFrom(new InternetAddress(userPrefs.getSmtpUsername()));
sender = userPrefs.getSmtpUsername();
} else {
sender = "no-reply@" + DatasetUtils.getDomainWithoutScheme(userPrefs);
}
msg.setFrom(new InternetAddress(sender));

// -- Set the TO field --
msg.setRecipients(Message.RecipientType.TO, InternetAddress.parse(recipientEmail, false));

if (ccEmail.length() > 0) {
Expand Down

0 comments on commit 298160a

Please sign in to comment.