Class MailSenderInitializer

java.lang.Object
best.skn.mail.services.impls.MailSenderInitializer

public class MailSenderInitializer extends Object
Mail Sender Initializer Class
Since:
2024-05-29
Version:
2.0.1
Author:
SKN Shukhan
Use Case:
Spring Boot Reactive
Dedicated To:
Logno, Atoshi and My Parents
  • Field Details

    • mailSender

      private org.springframework.mail.javamail.JavaMailSender mailSender
      Private Java Mail Sender property
      Since:
      v2.0.0
    • templateEngine

      private org.thymeleaf.TemplateEngine templateEngine
      private Thymeleaf Template Engine property
      Since:
      v2.0.0
    • message

      private jakarta.mail.internet.MimeMessage message
      private Mime Message property
      Since:
      v2.0.0
    • helper

      private org.springframework.mail.javamail.MimeMessageHelper helper
      private 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
      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 mails
      templateEngine - Thmeleaf Template Engine object for processing HTML templates
      Throws:
      jakarta.mail.MessagingException
      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 mail
      isHtml - Boolean parameter to set if a mail body will contain HTML template or not
      Throws:
      jakarta.mail.MessagingException
      Since:
      v2.0.0
    • sendMail

      protected void sendMail(MailSenderRequestInfo info) throws jakarta.mail.MessagingException
      Protected method to send basic mail
      Parameters:
      info - MailSenderRequestInfo object that contains all the information regarding sending mail
      Throws:
      jakarta.mail.MessagingException
      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
      IOException
      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 mail
      stream - MailSenderInputStream object that contains all the information regarding input stream
      Throws:
      jakarta.mail.MessagingException
      IOException
      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 mail
      template - MailSenderHtmlTemplate object that contains all the information regarding thymeleaf
      Throws:
      jakarta.mail.MessagingException
      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 mail
      template - MailSenderHtmlTemplate object that contains all the information regarding thymeleaf
      stream - MailSenderInputStream object that contains all the information regarding input stream
      Throws:
      jakarta.mail.MessagingException
      IOException
      Since:
      v2.0.0