Package best.skn.mail.services
Class MailSenderService
java.lang.Object
best.skn.mail.services.MailSenderService
- All Implemented Interfaces:
MailSenderInterface
Mail Sender Service Class
- Since:
- 2024-03-07
- Version:
- 1.2.1
- Author:
- SKN
- Use Case:
- Spring Boot Reactive
- Dedicated To:
- Trina, Logno and Atoshi
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate org.springframework.mail.javamail.JavaMailSenderPrivate Java Mail Sender objectprivate org.thymeleaf.TemplateEngineprivate Thymeleaf Template Engine object -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionreactor.core.publisher.Mono<String> Method to send basic mailreactor.core.publisher.Mono<String> Method to send basic mail with attachmentreactor.core.publisher.Mono<String> sendMailWithHtmlTemplate(String from, String to, String subject, String templateName, org.thymeleaf.context.Context context) Method to send mail with HTML templatereactor.core.publisher.Mono<String> sendMailWithHtmlTemplateAndAttachment(String from, String to, String subject, String templateName, org.thymeleaf.context.Context context, String filePath) Method to send mail with HTML template and attachment
-
Field Details
-
mailSender
@Autowired private org.springframework.mail.javamail.JavaMailSender mailSenderPrivate Java Mail Sender object- Since:
- v1.0.0
-
templateEngine
@Autowired private org.thymeleaf.TemplateEngine templateEngineprivate Thymeleaf Template Engine object- Since:
- v1.0.0
-
-
Constructor Details
-
MailSenderService
public MailSenderService()
-
-
Method Details
-
sendMail
public reactor.core.publisher.Mono<String> sendMail(String from, String to, String subject, String body) throws jakarta.mail.MessagingException Description copied from interface:MailSenderInterfaceMethod to send basic mail- Specified by:
sendMailin interfaceMailSenderInterface- Parameters:
from- a String which must be a valid email address from whom the mail will be sentto- a String which must be a valid email address to whom the mail will be sentsubject- a String containing the subject of the mailbody- a String containing the main body of the mail- Returns:
- a Mono of String as a response
- Throws:
jakarta.mail.MessagingException- a messaging exception if the mail is not sent successfully
-
sendMailWithAttachment
public reactor.core.publisher.Mono<String> sendMailWithAttachment(String from, String to, String subject, String body, String filePath) throws jakarta.mail.MessagingException Description copied from interface:MailSenderInterfaceMethod to send basic mail with attachment- Specified by:
sendMailWithAttachmentin interfaceMailSenderInterface- Parameters:
from- a String which must be a valid email address from whom the mail will be sentto- a String which must be a valid email address to whom the mail will be sentsubject- a String containing the subject of the mailbody- a String containing the main body of the mailfilePath- a String containing the file path to the attachment- Returns:
- a Mono of String as a response
- Throws:
jakarta.mail.MessagingException- a messaging exception if the mail is not sent successfully
-
sendMailWithHtmlTemplate
public reactor.core.publisher.Mono<String> sendMailWithHtmlTemplate(String from, String to, String subject, String templateName, org.thymeleaf.context.Context context) throws jakarta.mail.MessagingException Description copied from interface:MailSenderInterfaceMethod to send mail with HTML template- Specified by:
sendMailWithHtmlTemplatein interfaceMailSenderInterface- Parameters:
from- a String which must be a valid email address from whom the mail will be sentto- a String which must be a valid email address to whom the mail will be sentsubject- a String containing the subject of the mailtemplateName- a String containing the template name for the HTML templatecontext- a Thymeleaf Context for the HTML template- Returns:
- a Mono of String as a response
- Throws:
jakarta.mail.MessagingException- a messaging exception if the mail is not sent successfully
-
sendMailWithHtmlTemplateAndAttachment
public reactor.core.publisher.Mono<String> sendMailWithHtmlTemplateAndAttachment(String from, String to, String subject, String templateName, org.thymeleaf.context.Context context, String filePath) throws jakarta.mail.MessagingException Description copied from interface:MailSenderInterfaceMethod to send mail with HTML template and attachment- Specified by:
sendMailWithHtmlTemplateAndAttachmentin interfaceMailSenderInterface- Parameters:
from- a String which must be a valid email address from whom the mail will be sentto- a String which must be a valid email address to whom the mail will be sentsubject- a String containing the subject of the mailtemplateName- a String containing the template name for the HTML templatecontext- a Thymeleaf Context for the HTML templatefilePath- a String containing the file path to the attachment- Returns:
- a Mono of String as a response
- Throws:
jakarta.mail.MessagingException- a messaging exception if the mail is not sent successfully
-