Skip to content

Commit

Permalink
Merge pull request #6847 from ORCID/AddDoNotReplyToEmails
Browse files Browse the repository at this point in the history
notify.orcid.org and verify.orcid.org should be not reply addresses
  • Loading branch information
amontenegro authored Aug 16, 2023
2 parents 116a2a7 + 5f19f41 commit f2967f2
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 28 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,7 @@ public class EmailConstants {

public static final String LAST_RESORT_ORCID_USER_EMAIL_NAME = "ORCID Registry User";

public static final String SUPPORT_VERIFY_ORCID_ORG = "ORCID <[email protected]>";

public static final String RESET_NOTIFY_ORCID_ORG = "ORCID <[email protected]>";

public static final String CLAIM_NOTIFY_ORCID_ORG = "ORCID <[email protected]>";

public static final String DEACTIVATE_NOTIFY_ORCID_ORG = "ORCID <[email protected]>";

public static final String LOCKED_NOTIFY_ORCID_ORG = "ORCID <[email protected]>";

public static final String EMAIL_CHANGED_NOTIFY_ORCID_ORG = "ORCID <[email protected]>";
public static final String DO_NOT_REPLY_NOTIFY_ORCID_ORG = "ORCID - Do not reply <[email protected]>";

public static final String DO_NOT_REPLY_VERIFY_ORCID_ORG = "ORCID - Do not reply <[email protected]>";
}
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ public void sendOrcidLockedEmail(String orcidToLock) {
// Generate html from template
String html = templateManager.processTemplate("locked_orcid_email_html.ftl", templateParams);

mailgunManager.sendEmail(EmailConstants.LOCKED_NOTIFY_ORCID_ORG, email, subject, body, html);
mailgunManager.sendEmail(EmailConstants.DO_NOT_REPLY_NOTIFY_ORCID_ORG, email, subject, body, html);
}

private Locale getUserLocaleFromProfileEntity(ProfileEntity profile) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,6 @@
*/
public class EmailMessageSenderImpl implements EmailMessageSender {

private static final String DIGEST_FROM_ADDRESS = "[email protected]";
private static final Logger LOGGER = LoggerFactory.getLogger(EmailMessageSenderImpl.class);

private final Integer MAX_RETRY_COUNT;
Expand Down Expand Up @@ -299,7 +298,7 @@ public void sendEmailMessages() {
if(!notifications.isEmpty()) {
LOGGER.info("Found {} messages to send for orcid: {}", notifications.size(), orcid);
EmailMessage digestMessage = createDigest(orcid, notifications);
digestMessage.setFrom(DIGEST_FROM_ADDRESS);
digestMessage.setFrom(EmailConstants.DO_NOT_REPLY_NOTIFY_ORCID_ORG);
digestMessage.setTo(primaryEmail.getEmail());
boolean successfullySent = mailGunManager.sendEmail(digestMessage.getFrom(), digestMessage.getTo(), digestMessage.getSubject(),
digestMessage.getBodyText(), digestMessage.getBodyHtml());
Expand Down Expand Up @@ -395,7 +394,7 @@ private void processServiceAnnouncementOrTipNotification(NotificationEntity n, S
}
try {
boolean successfullySent = false;
String fromAddressParam = DIGEST_FROM_ADDRESS;
String fromAddressParam = EmailConstants.DO_NOT_REPLY_NOTIFY_ORCID_ORG;
if(!PojoUtil.isEmpty(fromAddress)) {
fromAddressParam = fromAddress;
}
Expand Down Expand Up @@ -624,6 +623,6 @@ private void sendVerificationReminderEmail(String userOrcid, String email) {
// Generate body from template
String body = templateManager.processTemplate("verification_email_v2.ftl", templateParams);
String htmlBody = templateManager.processTemplate("verification_email_html_v2.ftl", templateParams);
mailGunManager.sendEmail(EmailConstants.SUPPORT_VERIFY_ORCID_ORG, email, subject, body, htmlBody);
mailGunManager.sendEmail(EmailConstants.DO_NOT_REPLY_VERIFY_ORCID_ORG, email, subject, body, htmlBody);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ public void sendWelcomeEmail(String userOrcid, String email) {
// Generate html from template
String html = templateManager.processTemplate("welcome_email_html_v2.ftl", templateParams);

mailgunManager.sendEmail(EmailConstants.SUPPORT_VERIFY_ORCID_ORG, email, subject, body, html);
mailgunManager.sendEmail(EmailConstants.DO_NOT_REPLY_VERIFY_ORCID_ORG, email, subject, body, html);
}

public void sendOrcidDeactivateEmail(String userOrcid) {
Expand Down Expand Up @@ -159,7 +159,7 @@ public void sendOrcidDeactivateEmail(String userOrcid) {
// Generate html from template
String html = templateManager.processTemplate("deactivate_orcid_email_html.ftl", templateParams);

mailgunManager.sendEmail(EmailConstants.DEACTIVATE_NOTIFY_ORCID_ORG, email, subject, body, html);
mailgunManager.sendEmail(EmailConstants.DO_NOT_REPLY_NOTIFY_ORCID_ORG, email, subject, body, html);
}

public void sendOrcidLockedEmail(String orcidToLock) {
Expand All @@ -184,7 +184,7 @@ public void sendOrcidLockedEmail(String orcidToLock) {
// Generate html from template
String html = templateManager.processTemplate("locked_orcid_email_html.ftl", templateParams);

mailgunManager.sendEmail(EmailConstants.LOCKED_NOTIFY_ORCID_ORG, email, subject, body, html);
mailgunManager.sendEmail(EmailConstants.DO_NOT_REPLY_NOTIFY_ORCID_ORG, email, subject, body, html);
}

public void sendPasswordResetEmail(String submittedEmail, String userOrcid) {
Expand All @@ -208,7 +208,7 @@ public void sendPasswordResetEmail(String submittedEmail, String userOrcid) {
// Generate body from template
String body = templateManager.processTemplate("reset_password_email.ftl", templateParams);
String htmlBody = templateManager.processTemplate("reset_password_email_html.ftl", templateParams);
mailgunManager.sendEmail(EmailConstants.RESET_NOTIFY_ORCID_ORG, submittedEmail, verifyEmailUtils.getSubject("email.subject.reset", locale), body, htmlBody);
mailgunManager.sendEmail(EmailConstants.DO_NOT_REPLY_NOTIFY_ORCID_ORG, submittedEmail, verifyEmailUtils.getSubject("email.subject.reset", locale), body, htmlBody);
}

public void sendPasswordResetNotFoundEmail(String submittedEmail, Locale locale) {
Expand All @@ -222,7 +222,7 @@ public void sendPasswordResetNotFoundEmail(String submittedEmail, Locale locale)
// Generate body from template
String body = templateManager.processTemplate("reset_password_not_found_email.ftl", templateParams);
String htmlBody = templateManager.processTemplate("reset_password_not_found_email_html.ftl", templateParams);
mailgunManager.sendEmail(EmailConstants.RESET_NOTIFY_ORCID_ORG, submittedEmail, verifyEmailUtils.getSubject("email.subject.reset_not_found", locale), body, htmlBody);
mailgunManager.sendEmail(EmailConstants.DO_NOT_REPLY_NOTIFY_ORCID_ORG, submittedEmail, verifyEmailUtils.getSubject("email.subject.reset_not_found", locale), body, htmlBody);
}

public void sendReactivationEmail(String submittedEmail, String userOrcid) {
Expand All @@ -245,7 +245,7 @@ public void sendReactivationEmail(String submittedEmail, String userOrcid) {
// Generate body from template
String body = templateManager.processTemplate("reactivation_email.ftl", templateParams);
String htmlBody = templateManager.processTemplate("reactivation_email_html.ftl", templateParams);
mailgunManager.sendEmail(EmailConstants.RESET_NOTIFY_ORCID_ORG, submittedEmail, verifyEmailUtils.getSubject("email.subject.reactivation", locale), body, htmlBody);
mailgunManager.sendEmail(EmailConstants.DO_NOT_REPLY_NOTIFY_ORCID_ORG, submittedEmail, verifyEmailUtils.getSubject("email.subject.reactivation", locale), body, htmlBody);
}

public void sendEmailAddressChangedNotification(String currentUserOrcid, String newEmail, String oldEmail) {
Expand Down Expand Up @@ -274,7 +274,7 @@ public void sendEmailAddressChangedNotification(String currentUserOrcid, String
// Generate html from template
String html = templateManager.processTemplate("email_removed_html.ftl", templateParams);

mailgunManager.sendEmail(EmailConstants.EMAIL_CHANGED_NOTIFY_ORCID_ORG, oldEmail, subject, body, html);
mailgunManager.sendEmail(EmailConstants.DO_NOT_REPLY_NOTIFY_ORCID_ORG, oldEmail, subject, body, html);
}

public void sendClaimReminderEmail(String userOrcid, int daysUntilActivation, String email) {
Expand Down Expand Up @@ -334,7 +334,7 @@ public void sendClaimReminderEmail(String userOrcid, int daysUntilActivation, St

// Send message
if (apiRecordCreationEmailEnabled) {
mailgunManager.sendEmail(EmailConstants.CLAIM_NOTIFY_ORCID_ORG, email, verifyEmailUtils.getSubject("email.subject.claim_reminder", locale), body, htmlBody);
mailgunManager.sendEmail(EmailConstants.DO_NOT_REPLY_NOTIFY_ORCID_ORG, email, verifyEmailUtils.getSubject("email.subject.claim_reminder", locale), body, htmlBody);
profileEventDao.persist(new ProfileEventEntity(userOrcid, ProfileEventType.CLAIM_REMINDER_SENT));
} else {
LOGGER.debug("Not sending claim reminder email, because API record creation email option is disabled. Message would have been: {}", body);
Expand Down Expand Up @@ -364,7 +364,7 @@ public void send2FADisabledEmail(String userOrcid) {
String html = templateManager.processTemplate("email_2fa_disabled_html.ftl", templateParams);

for (Email email : emails.getEmails()) {
mailgunManager.sendEmail(EmailConstants.RESET_NOTIFY_ORCID_ORG, email.getEmail(), subject, body, html);
mailgunManager.sendEmail(EmailConstants.DO_NOT_REPLY_NOTIFY_ORCID_ORG, email.getEmail(), subject, body, html);
}
}

Expand All @@ -382,7 +382,7 @@ public void sendForgottenIdEmail(String email, String orcid) {

String body = templateManager.processTemplate("forgot_id_email.ftl", templateParams);
String htmlBody = templateManager.processTemplate("forgot_id_email_html.ftl", templateParams);
mailgunManager.sendEmail(EmailConstants.RESET_NOTIFY_ORCID_ORG, email, verifyEmailUtils.getSubject("email.subject.forgotten_id", locale), body, htmlBody);
mailgunManager.sendEmail(EmailConstants.DO_NOT_REPLY_NOTIFY_ORCID_ORG, email, verifyEmailUtils.getSubject("email.subject.forgotten_id", locale), body, htmlBody);
}

public void sendForgottenIdEmailNotFoundEmail(String email, Locale locale) {
Expand All @@ -395,7 +395,7 @@ public void sendForgottenIdEmailNotFoundEmail(String email, Locale locale) {

String body = templateManager.processTemplate("forgot_id_email_not_found_email.ftl", templateParams);
String htmlBody = templateManager.processTemplate("forgot_id_email_not_found_email_html.ftl", templateParams);
mailgunManager.sendEmail(EmailConstants.RESET_NOTIFY_ORCID_ORG, email, verifyEmailUtils.getSubject("email.subject.forgotten_id", locale), body, htmlBody);
mailgunManager.sendEmail(EmailConstants.DO_NOT_REPLY_NOTIFY_ORCID_ORG, email, verifyEmailUtils.getSubject("email.subject.forgotten_id", locale), body, htmlBody);
}

public void sendVerificationEmailToNonPrimaryEmails(String userOrcid) {
Expand All @@ -420,7 +420,7 @@ private void processVerificationEmail(String userOrcid, String email, boolean is
// Generate body from template
String body = templateManager.processTemplate("verification_email_v2.ftl", templateParams);
String htmlBody = templateManager.processTemplate("verification_email_html_v2.ftl", templateParams);
mailgunManager.sendEmail(EmailConstants.SUPPORT_VERIFY_ORCID_ORG, email, subject, body, htmlBody);
mailgunManager.sendEmail(EmailConstants.DO_NOT_REPLY_VERIFY_ORCID_ORG, email, subject, body, htmlBody);
}

private Locale getUserLocaleFromProfileEntity(ProfileEntity profile) {
Expand Down

0 comments on commit f2967f2

Please sign in to comment.