Class PdfferMailerBean

java.lang.Object
org.nekosoft.pdffer.mail.PdfferMailerBean

@Component @ConditionalOnClass(name="org.springframework.mail.javamail.JavaMailSenderImpl") @ConditionalOnProperty(name="pdffer.mailer.beans.enable", havingValue="true", matchIfMissing=false) public class PdfferMailerBean extends Object

The PDFfer mailer bean.

This bean is used to send emails with PDF attachments directly from PDFfer. It requires that the mail dependencies are present in the Spring Boot application (the spring-boot-starter-mail artifact) and that the pdffer.mailer.beans.enable property is set to true.

This class has methods that will take PDF content as an array of bytes and will send it over to the given email address or addresses.

  • Constructor Details

    • PdfferMailerBean

      public PdfferMailerBean(org.springframework.mail.javamail.JavaMailSender mailSender, PdfferMailerProps props)
      Allows Spring to create the bean instance and pass the JavaMailSender and PdfferMailerProps instances into it.
      Parameters:
      mailSender - the mail sender
      props - the props
  • Method Details

    • sendMessageWithPdfAttachment

      public void sendMessageWithPdfAttachment(String toString, String subject, String text, byte[] attachment, String filename, String sendFrom, String replyTo) throws MailAddressException, MailMessageException, MailSenderException
      Send an email message with a PDF attachment.
      Parameters:
      toString - the email addresses to send the email to as a comma-separated string
      subject - the subject of the email
      text - the text of the main message of the email
      attachment - the attachment PDF as an array of bytes
      filename - the filename of the attachment
      sendFrom - the send-from email address (can be null)
      replyTo - the reply-to email address (can be null)
      Throws:
      MailAddressException - the MailAddressException raised if invalid email addresses were found
      MailMessageException - the MailMessageException raised if any issues were encountered while creating the message body
      MailSenderException - the MailSenderException raised if any issues were encountered while sending email
    • sendMessageWithPdfAttachmentToList

      public void sendMessageWithPdfAttachmentToList(List<String> toList, String subject, String text, byte[] attachment, String filename, String sendFrom, String replyTo) throws MailAddressException, MailMessageException, MailSenderException
      Send an email message with a PDF attachment.
      Parameters:
      toList - the email addresses to send the email to as a list of strings
      subject - the subject of the email
      text - the text of the main message of the email
      attachment - the attachment PDF as an array of bytes
      filename - the filename of the attachment
      sendFrom - the send-from email address (can be null)
      replyTo - the reply-to email address (can be null)
      Throws:
      MailAddressException - the MailAddressException raised if invalid email addresses were found
      MailMessageException - the MailMessageException raised if any issues were encountered while creating the message body
      MailSenderException - the MailSenderException raised if any issues were encountered while sending email
    • sendMessageWithPdfAttachment

      public void sendMessageWithPdfAttachment(List<javax.mail.internet.InternetAddress> to, String subject, String text, byte[] attachment, String filename, String sendFrom, String replyTo) throws MailAddressException, MailMessageException, MailSenderException
      Send an email message with a PDF attachment.
      Parameters:
      to - the email addresses to send the email to as a java.util.List of javax.mail.internet.InternetAddress
      subject - the subject of the email
      text - the text of the main message of the email
      attachment - the attachment PDF as an array of bytes
      filename - the filename of the attachment
      sendFrom - the send-from email address (can be null)
      replyTo - the reply-to email address (can be null)
      Throws:
      MailAddressException - the MailAddressException raised if invalid email addresses were found
      MailMessageException - the MailMessageException raised if any issues were encountered while creating the message body
      MailSenderException - the MailSenderException raised if any issues were encountered while sending email