Class MailSenderInitializer
java.lang.Object
best.skn.mail.services.impls.MailSenderInitializer
Mail Sender Initializer Class
- Since:
- 2024-05-29
- Version:
- 2.2.0
- Author:
- SKN Shukhan
- Use Case:
- Spring Boot Reactive
- Dedicated To:
- Logno, Atoshi and My Parents
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate org.springframework.mail.javamail.MimeMessageHelperprivate Mime Message Helper propertyprivate org.springframework.mail.javamail.JavaMailSenderPrivate Java Mail Sender propertyprivate jakarta.mail.internet.MimeMessageprivate Mime Message propertyprivate org.thymeleaf.TemplateEngineprivate Thymeleaf Template Engine property -
Constructor Summary
ConstructorsConstructorDescriptionMailSenderInitializer(org.springframework.mail.javamail.JavaMailSender mailSender) Constructor for this class with one parameterMailSenderInitializer(org.springframework.mail.javamail.JavaMailSender mailSender, org.thymeleaf.TemplateEngine templateEngine) Constructor for this class with two parameters -
Method Summary
Modifier and TypeMethodDescriptionprotected voidProtected method to send basic mailprotected voidsendMailWithAttachment(MailSenderRequestInfo info, MailSenderInputStream stream) Protected method to send mail with attachmentprotected voidsendMailWithHtmlTemplate(MailSenderRequestInfo info, MailSenderHtmlTemplate template) Protected method to send mail with HTML templateprotected voidsendMailWithHtmlTemplateAndAttachment(MailSenderRequestInfo info, MailSenderHtmlTemplate template, MailSenderInputStream stream) Protected method to send mail with HTML template and attachmentprivate voidsendMessage(MailSenderRequestInfo info, boolean isHtml) Private method to set the required info to send a mail and then send itprivate voidPrivate method to set the required configuration regarding file attachment
-
Field Details
-
mailSender
private org.springframework.mail.javamail.JavaMailSender mailSenderPrivate Java Mail Sender property- Since:
- v2.0.0
-
templateEngine
private org.thymeleaf.TemplateEngine templateEngineprivate Thymeleaf Template Engine property- Since:
- v2.0.0
-
message
private jakarta.mail.internet.MimeMessage messageprivate Mime Message property- Since:
- v2.0.0
-
helper
private org.springframework.mail.javamail.MimeMessageHelper helperprivate Mime Message Helper property- Since:
- v2.0.0
-
-
Constructor Details
-
MailSenderInitializer
public MailSenderInitializer(org.springframework.mail.javamail.JavaMailSender mailSender) throws jakarta.mail.MessagingException Constructor for this class with one parameter- Parameters:
mailSender- Java Mail Sender object for sending mails- Throws:
jakarta.mail.MessagingException- an exception is thrown if an error occurs while sending mail- Since:
- v2.0.0
-
MailSenderInitializer
public MailSenderInitializer(org.springframework.mail.javamail.JavaMailSender mailSender, org.thymeleaf.TemplateEngine templateEngine) throws jakarta.mail.MessagingException Constructor for this class with two parameters- Parameters:
mailSender- Java Mail Sender object for sending mailstemplateEngine- Thmeleaf Template Engine object for processing HTML templates- Throws:
jakarta.mail.MessagingException- an exception is thrown if an error occurs while sending mail- Since:
- v2.0.0
-
-
Method Details
-
sendMessage
private void sendMessage(MailSenderRequestInfo info, boolean isHtml) throws jakarta.mail.MessagingException Private method to set the required info to send a mail and then send it- Parameters:
info- MailSenderRequestInfo object that contains all the information regarding sending mailisHtml- Boolean parameter to set if a mail body will contain HTML template or not- Throws:
jakarta.mail.MessagingException- an exception is thrown if an error occurs while sending mail- Since:
- v2.0.0
-
sendMail
Protected method to send basic mail- Parameters:
info- MailSenderRequestInfo object that contains all the information regarding sending mail- Throws:
jakarta.mail.MessagingException- an exception is thrown if an error occurs while sending mail- Since:
- v2.0.0
-
streamAttachement
private void streamAttachement(MailSenderInputStream stream) throws jakarta.mail.MessagingException, IOException Private method to set the required configuration regarding file attachment- Parameters:
stream- MailSenderInputStream object that contains all the information regarding input stream- Throws:
jakarta.mail.MessagingException- an exception is thrown if an error occurs while sending mailIOException- an exception is thrown if an error occurs in file attachment- Since:
- v2.0.0
-
sendMailWithAttachment
protected void sendMailWithAttachment(MailSenderRequestInfo info, MailSenderInputStream stream) throws jakarta.mail.MessagingException, IOException Protected method to send mail with attachment- Parameters:
info- MailSenderRequestInfo object that contains all the information regarding sending mailstream- MailSenderInputStream object that contains all the information regarding input stream- Throws:
jakarta.mail.MessagingException- an exception is thrown if an error occurs while sending mailIOException- an exception is thrown if an error occurs in file attachment- Since:
- v2.0.0
-
sendMailWithHtmlTemplate
protected void sendMailWithHtmlTemplate(MailSenderRequestInfo info, MailSenderHtmlTemplate template) throws jakarta.mail.MessagingException Protected method to send mail with HTML template- Parameters:
info- MailSenderRequestInfo object that contains all the information regarding sending mailtemplate- MailSenderHtmlTemplate object that contains all the information regarding thymeleaf- Throws:
jakarta.mail.MessagingException- an exception is thrown if an error occurs while sending mail- Since:
- v2.0.0
-
sendMailWithHtmlTemplateAndAttachment
protected void sendMailWithHtmlTemplateAndAttachment(MailSenderRequestInfo info, MailSenderHtmlTemplate template, MailSenderInputStream stream) throws jakarta.mail.MessagingException, IOException Protected method to send mail with HTML template and attachment- Parameters:
info- MailSenderRequestInfo object that contains all the information regarding sending mailtemplate- MailSenderHtmlTemplate object that contains all the information regarding thymeleafstream- MailSenderInputStream object that contains all the information regarding input stream- Throws:
jakarta.mail.MessagingException- an exception is thrown if an error occurs while sending mailIOException- an exception is thrown if an error occurs in file attachment- Since:
- v2.0.0
-