Package org.craftercms.commons.mail.impl
Class EmailFactoryImpl
java.lang.Object
org.craftercms.commons.mail.impl.EmailFactoryImpl
- All Implemented Interfaces:
EmailFactory
Default implementation of
EmailFactory.- Author:
- avasquez
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionEmailFactoryImpl(org.springframework.mail.javamail.JavaMailSender mailSender) -
Method Summary
Modifier and TypeMethodDescriptionprotected jakarta.mail.internet.MimeMessagecreateMessage(String from, String[] to, String[] cc, String[] bcc, String replyTo, String subject, String body, boolean html, File... attachments) getEmail(String from, String[] to, String[] cc, String[] bcc, String subject, String body, boolean html, File... attachments) Creates a newEmail.getEmail(String from, String[] to, String[] cc, String[] bcc, String subject, String templateName, Object templateModel, boolean html, File... attachments) Creates a newEmail.getEmail(String from, String[] to, String[] cc, String[] bcc, String replyTo, String subject, String body, boolean html, File... attachments) Creates a newEmail.getEmail(String from, String[] to, String[] cc, String[] bcc, String replyTo, String subject, String templateName, Object templateModel, boolean html, File... attachments) Creates a newEmail.protected StringprocessTemplate(String templateName, Object templateModel) voidsetFreeMarkerConfig(freemarker.template.Configuration freeMarkerConfig) voidsetTemplateEncoding(String templateEncoding) voidsetTemplatePrefix(String templatePrefix) voidsetTemplateSuffix(String templateSuffix)
-
Field Details
-
DEFAULT_ENCODING
- See Also:
-
LOG_KEY_MIME_MSG_CREATED
- See Also:
-
LOG_KEY_PROCESSING_EMAIL_TEMPLATE
- See Also:
-
ERROR_KEY_TEMPLATE_CONFIG_MISSING
- See Also:
-
mailSender
protected org.springframework.mail.javamail.JavaMailSender mailSender -
freeMarkerConfig
protected freemarker.template.Configuration freeMarkerConfig -
templatePrefix
-
templateSuffix
-
templateEncoding
-
-
Constructor Details
-
EmailFactoryImpl
public EmailFactoryImpl(org.springframework.mail.javamail.JavaMailSender mailSender)
-
-
Method Details
-
setFreeMarkerConfig
public void setFreeMarkerConfig(freemarker.template.Configuration freeMarkerConfig) -
setTemplatePrefix
-
setTemplateSuffix
-
setTemplateEncoding
-
getEmail
public Email getEmail(String from, String[] to, String[] cc, String[] bcc, String subject, String body, boolean html, File... attachments) throws EmailException Description copied from interface:EmailFactoryCreates a newEmail.- Specified by:
getEmailin interfaceEmailFactory- Parameters:
from- the sender's addressto- the recipients' addresses (optional)cc- the CC recipients' addresses (optional)bcc- the BCC recipients' addresses (optional)subject- the subject of the emailbody- the text body of the emailhtml- if the body is in HTML formatattachments- the attachments to add to the email- Returns:
- the created email
- Throws:
EmailException
-
getEmail
public Email getEmail(String from, String[] to, String[] cc, String[] bcc, String replyTo, String subject, String body, boolean html, File... attachments) throws EmailException Description copied from interface:EmailFactoryCreates a newEmail.- Specified by:
getEmailin interfaceEmailFactory- Parameters:
from- the sender's addressto- the recipients' addresses (optional)cc- the CC recipients' addresses (optional)bcc- the BCC recipients' addresses (optional)replyTo- the address to reply tosubject- the subject of the emailbody- the text body of the emailhtml- if the body is in HTML format- Returns:
- the created email
- Throws:
EmailException
-
getEmail
public Email getEmail(String from, String[] to, String[] cc, String[] bcc, String subject, String templateName, Object templateModel, boolean html, File... attachments) throws EmailException Description copied from interface:EmailFactoryCreates a newEmail.- Specified by:
getEmailin interfaceEmailFactory- Parameters:
from- the sender's addressto- the recipients' addresses (optional)cc- the CC recipients' addresses (optional)bcc- the BCC recipients' addresses (optional)subject- the subject of the emailtemplateName- the template name of the emailtemplateModel- the template model of the emailhtml- if the body is in HTML format- Returns:
- the created email
- Throws:
EmailException
-
getEmail
public Email getEmail(String from, String[] to, String[] cc, String[] bcc, String replyTo, String subject, String templateName, Object templateModel, boolean html, File... attachments) throws EmailException Description copied from interface:EmailFactoryCreates a newEmail.- Specified by:
getEmailin interfaceEmailFactory- Parameters:
from- the sender's addressto- the recipients' addresses (optional)cc- the CC recipients' addresses (optional)bcc- the BCC recipients' addresses (optional)replyTo- the address to reply tosubject- the subject of the emailtemplateName- the template name of the emailtemplateModel- the template model of the emailhtml- if the body is in HTML format- Returns:
- the created email
- Throws:
EmailException
-
createMessage
protected jakarta.mail.internet.MimeMessage createMessage(String from, String[] to, String[] cc, String[] bcc, String replyTo, String subject, String body, boolean html, File... attachments) throws EmailException - Throws:
EmailException
-
processTemplate
- Throws:
EmailException
-