From: Mark Cooper Date: Tue, 6 Apr 2021 00:09:34 +0000 (-0700) Subject: Ensure from is set for mail (resolves sendgrid smtp error) X-Git-Url: https://git.aero2k.de/?a=commitdiff_plain;h=3459501f995b5061b8a532ff708b9fe9a15e288a;p=tmp%2Fjakarta-migration.git Ensure from is set for mail (resolves sendgrid smtp error) --- diff --git a/services/common/src/main/java/org/collectionspace/services/common/EmailUtil.java b/services/common/src/main/java/org/collectionspace/services/common/EmailUtil.java index 103154f21..29ecabdf0 100644 --- a/services/common/src/main/java/org/collectionspace/services/common/EmailUtil.java +++ b/services/common/src/main/java/org/collectionspace/services/common/EmailUtil.java @@ -8,6 +8,7 @@ import javax.mail.MessagingException; import javax.mail.Session; import javax.mail.Transport; import javax.mail.internet.MimeMessage; +import javax.mail.internet.InternetAddress; import org.collectionspace.services.config.tenant.EmailConfig; @@ -48,6 +49,7 @@ public class EmailUtil { try { msg.setRecipients(Message.RecipientType.TO, recipient); + msg.setFrom(new InternetAddress(props.getProperty("mail.from"))); msg.setSubject("JavaMail hello world example"); msg.setSentDate(new Date()); msg.setText("Hello, world!\n"); @@ -83,6 +85,7 @@ public class EmailUtil { try { msg.setRecipients(Message.RecipientType.TO, recipients); + msg.setFrom(new InternetAddress(emailConfig.getFrom())); msg.setSubject(emailConfig.getPasswordResetConfig().getSubject()); msg.setSentDate(new Date()); msg.setText(message);