Class MailUtil
java.lang.Object
jp.ecuacion.lib.core.util.MailUtil
Provides mail-related utility methods.
-
Method Summary
Modifier and TypeMethodDescriptionstatic voidsendErrorMail(Throwable throwable) Sends an error mail.static voidsendErrorMail(Throwable throwable, String additionalMessage) Sends an error mail adding an additional message to it.static voidProvides sending html-format mail function.static voidProvides sending text-format mail function.static voidsendWarnMail(String content, List<String> mailToList) Sends a warn mail.
-
Method Details
-
sendErrorMail
Sends an error mail.This is used in exception handler to notify system administrator the occurence of an error.
The mail is sent to the addresses defined in
application.propertieswith keyjp.ecuacion.lib.core.mail.address-csv-on-system-error.- Parameters:
throwable- throwable
-
sendErrorMail
public static void sendErrorMail(@RequireNonnull Throwable throwable, @Nullable String additionalMessage) Sends an error mail adding an additional message to it.- Parameters:
throwable- throwable.additionalMessage- additional message, may benullif noadditionalMessageis needed. In the case ofnullno additional message is output.
-
sendWarnMail
@Nonnull public static void sendWarnMail(@Nullable String content, @RequireNonnull List<String> mailToList) Sends a warn mail.- Parameters:
content- content, may benullif no mailbody content needed.mailToList- list of mailadresses used for "TO" address
-
sendTextMail
public static void sendTextMail(@Nullable List<String> mailToList, @Nullable List<String> mailCcList, @RequireNonnull String title, @Nullable String content) throws Exception Provides sending text-format mail function.The following settings ars needed to application.properties to send mails with this object.
# true or false SMTP_AUTHENTICATION=true #Normally "true" if the port number is 465, "false" if 587 SMTP_SSL_ENABLED=true jp.ecuacion.lib.core.mail.smtp.server=smtp.gmail.com jp.ecuacion.lib.core.mail.smtp.port=465 jp.ecuacion.lib.core.mail.smtp.sender=info@ecuacion.jp jp.ecuacion.lib.core.mail.smtp.password=(password) jp.ecuacion.lib.core.mail.title-prefix=[app-name: staging environment] jp.ecuacion.lib.core.mail.address-csv-on-system-error=info@ecuacion.jp
- Parameters:
mailToList- mailToList. Either mailToList or mailCcList need to have at least one element.mailCcList- mailCcList. Either mailToList or mailCcList need to have at least one element.title- titlecontent- content, may benullif no content needed.- Throws:
Exception- Exception
-
sendHtmlMail
-