From 3459501f995b5061b8a532ff708b9fe9a15e288a Mon Sep 17 00:00:00 2001 From: Mark Cooper Date: Mon, 5 Apr 2021 17:09:34 -0700 Subject: [PATCH] Ensure from is set for mail (resolves sendgrid smtp error) --- .../java/org/collectionspace/services/common/EmailUtil.java | 3 +++ 1 file changed, 3 insertions(+) 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); -- 2.47.3