Logged the Email Messages which are not sent as smpt settings is not … (#11650)

* logged the Email Messages which are not sent as smpt settings is not enabled

* modified change event message

* used a genric message for all

* logs a genric message with email id

---------

Co-authored-by: Himank Mehta <himankmehta@Himanks-MacBook-Air.local>
This commit is contained in:
07Himank 2023-05-18 19:03:14 +05:30 committed by GitHub
parent 8795337f88
commit 4d2bbb3b75
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -89,6 +89,8 @@ public class EmailUtil {
private static Mailer MAILER;
private static Configuration TEMPLATE_CONFIGURATION;
private static final String EMAIL_IGNORE_MSG = "Email was not sent to %s as SMTP setting is not enabled";
private EmailUtil() {
try {
STORED_SMTP_SETTINGS = getSmtpSettings();
@ -146,6 +148,8 @@ public class EmailUtil {
user.getEmail(),
EMAIL_TEMPLATE_BASEPATH,
ACCOUNT_STATUS_TEMPLATE_FILE);
} else {
LOG.warn(String.format(EMAIL_IGNORE_MSG, user.getEmail()));
}
}
@ -163,6 +167,8 @@ public class EmailUtil {
user.getEmail(),
EMAIL_TEMPLATE_BASEPATH,
EMAIL_VERIFICATION_TEMPLATE_PATH);
} else {
LOG.warn(String.format(EMAIL_IGNORE_MSG, user.getEmail()));
}
}
@ -177,6 +183,8 @@ public class EmailUtil {
templatePopulator.put(EXPIRATION_TIME_KEY, DEFAULT_EXPIRATION_TIME);
sendMail(subject, templatePopulator, user.getEmail(), EMAIL_TEMPLATE_BASEPATH, templateFilePath);
} else {
LOG.warn(String.format(EMAIL_IGNORE_MSG, user.getEmail()));
}
}
@ -195,6 +203,8 @@ public class EmailUtil {
templatePopulator.put("taskLink", taskLink);
sendMail(subject, templatePopulator, email, EMAIL_TEMPLATE_BASEPATH, templateFilePath);
} else {
LOG.warn(String.format(EMAIL_IGNORE_MSG, email));
}
}
@ -237,6 +247,8 @@ public class EmailUtil {
String mailContent = stringWriter.toString();
emailBuilder.withHTMLText(mailContent);
sendMail(emailBuilder.buildEmail());
} else {
LOG.warn(EMAIL_IGNORE_MSG, to);
}
}
@ -299,6 +311,8 @@ public class EmailUtil {
} catch (Exception ex) {
LOG.error("Failed in sending Mail to user [{}]. Reason : {}", user.getEmail(), ex.getMessage());
}
} else {
LOG.warn(String.format(EMAIL_IGNORE_MSG, user.getEmail()));
}
}
@ -325,6 +339,8 @@ public class EmailUtil {
} catch (Exception ex) {
LOG.error("Failed in sending Mail to user [{}]. Reason : {}", receiverMail, ex.getMessage());
}
} else {
LOG.warn(String.format(EMAIL_IGNORE_MSG, receiverMail));
}
}
@ -344,6 +360,8 @@ public class EmailUtil {
templatePopulator.put("ownershipObj", ownerShipObj);
templatePopulator.put("tierObj", tierObj);
sendMailToMultiple(subject, templatePopulator, emails, EMAIL_TEMPLATE_BASEPATH, templateFilePath);
} else {
LOG.warn(EMAIL_IGNORE_MSG, emails.toString());
}
}