Package org.nekosoft.pdffer.mail
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 Summary
ConstructorDescriptionPdfferMailerBean(org.springframework.mail.javamail.JavaMailSender mailSender, PdfferMailerProps props)
Allows Spring to create the bean instance and pass theJavaMailSender
andPdfferMailerProps
instances into it. -
Method Summary
Modifier and TypeMethodDescriptionvoid
sendMessageWithPdfAttachment(String toString, String subject, String text, byte[] attachment, String filename, String sendFrom, String replyTo)
Send an email message with a PDF attachment.void
sendMessageWithPdfAttachment(List<javax.mail.internet.InternetAddress> to, String subject, String text, byte[] attachment, String filename, String sendFrom, String replyTo)
Send an email message with a PDF attachment.void
sendMessageWithPdfAttachmentToList(List<String> toList, String subject, String text, byte[] attachment, String filename, String sendFrom, String replyTo)
Send an email message with a PDF attachment.
-
Constructor Details
-
PdfferMailerBean
public PdfferMailerBean(org.springframework.mail.javamail.JavaMailSender mailSender, PdfferMailerProps props)Allows Spring to create the bean instance and pass theJavaMailSender
andPdfferMailerProps
instances into it.- Parameters:
mailSender
- the mail senderprops
- 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, MailSenderExceptionSend an email message with a PDF attachment.- Parameters:
toString
- the email addresses to send the email to as a comma-separated stringsubject
- the subject of the emailtext
- the text of the main message of the emailattachment
- the attachment PDF as an array of bytesfilename
- the filename of the attachmentsendFrom
- the send-from email address (can be null)replyTo
- the reply-to email address (can be null)- Throws:
MailAddressException
- theMailAddressException
raised if invalid email addresses were foundMailMessageException
- theMailMessageException
raised if any issues were encountered while creating the message bodyMailSenderException
- theMailSenderException
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, MailSenderExceptionSend an email message with a PDF attachment.- Parameters:
toList
- the email addresses to send the email to as a list of stringssubject
- the subject of the emailtext
- the text of the main message of the emailattachment
- the attachment PDF as an array of bytesfilename
- the filename of the attachmentsendFrom
- the send-from email address (can be null)replyTo
- the reply-to email address (can be null)- Throws:
MailAddressException
- theMailAddressException
raised if invalid email addresses were foundMailMessageException
- theMailMessageException
raised if any issues were encountered while creating the message bodyMailSenderException
- theMailSenderException
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, MailSenderExceptionSend an email message with a PDF attachment.- Parameters:
to
- the email addresses to send the email to as ajava.util.List
ofjavax.mail.internet.InternetAddress
subject
- the subject of the emailtext
- the text of the main message of the emailattachment
- the attachment PDF as an array of bytesfilename
- the filename of the attachmentsendFrom
- the send-from email address (can be null)replyTo
- the reply-to email address (can be null)- Throws:
MailAddressException
- theMailAddressException
raised if invalid email addresses were foundMailMessageException
- theMailMessageException
raised if any issues were encountered while creating the message bodyMailSenderException
- theMailSenderException
raised if any issues were encountered while sending email
-