Class EmailSender
java.lang.Object
org.craftercms.commons.notification.NotificationSender<EmailSender.EmailMessage>
org.craftercms.commons.notification.impl.EmailSender
- All Implemented Interfaces:
AutoCloseable
NotificationSender implementation that sends an email notification.
The output file is attached if it's available. An EmailSender instance can be configured (see init(org.apache.commons.configuration2.Configuration)) with
the following Configuration properties:
- from: The value of the From field in the emails.
- to: The value of the To field in the emails.
- subject: The value of the Subject field in the emails.
- html: Whether the emails are HTML.
NotificationSender for the common properties available to all notification senders.-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprotected classNotificationSender<EmailSender.EmailMessage>.NotificationMessageextension that includes a file attachment.Nested classes/interfaces inherited from class org.craftercms.commons.notification.NotificationSender
NotificationSender.NotificationMessage -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final EmailFactoryprotected Stringstatic final Stringprotected booleanstatic final Stringstatic final Stringprotected Stringstatic final Stringprotected String[]static final StringFields inherited from class org.craftercms.commons.notification.NotificationSender
DATETIME_FORMATTER_MODEL_KEY, DATETIME_PATTERN_CONFIG_KEY, dateTimeFormatter, DURATION_FORMATTER_MODEL_KEY, DURATION_PATTERN_CONFIG_KEY, durationFormatter, freeMarkerConfig, objectMapper, PAYLOAD_MODEL_KEY, templateEncoding, templatePrefix, templateSuffix -
Constructor Summary
ConstructorsConstructorDescriptionEmailSender(freemarker.template.Configuration freeMarkerConfig, com.fasterxml.jackson.databind.ObjectMapper objectMapper, String dateTimePattern, String durationPattern, EmailFactory emailFactory, String from, String subject, boolean html) -
Method Summary
Modifier and TypeMethodDescriptionprotected EmailSender.EmailMessagedoCreateMessage(String templateName, Object payload) Creates the notification message to send.protected voiddoNotify(EmailSender.EmailMessage message) Sends the notification message.voidinit(org.apache.commons.configuration2.Configuration config) voidvoidMethods inherited from class org.craftercms.commons.notification.NotificationSender
close, createMessage, initProperties, processTemplate, sendMessage, setTemplateEncoding, setTemplatePrefix, setTemplateSuffix
-
Field Details
-
FROM_CONFIG_KEY
- See Also:
-
TO_CONFIG_KEY
- See Also:
-
SUBJECT_CONFIG_KEY
- See Also:
-
HTML_CONFIG_KEY
- See Also:
-
OUTPUT_ATTACHED_MODEL_KEY
- See Also:
-
emailFactory
-
from
-
to
-
subject
-
html
protected boolean html
-
-
Constructor Details
-
EmailSender
@ConstructorProperties({"freeMarkerConfig","objectMapper","dateTimePattern","durationPattern","emailFactory","from","subject","html"}) public EmailSender(freemarker.template.Configuration freeMarkerConfig, com.fasterxml.jackson.databind.ObjectMapper objectMapper, String dateTimePattern, String durationPattern, EmailFactory emailFactory, String from, String subject, boolean html)
-
-
Method Details
-
init
public void init(org.apache.commons.configuration2.Configuration config) throws ConfigurationException - Overrides:
initin classNotificationSender<EmailSender.EmailMessage>- Throws:
ConfigurationException
-
doNotify
Description copied from class:NotificationSenderSends the notification message.- Specified by:
doNotifyin classNotificationSender<EmailSender.EmailMessage>- Parameters:
message- the notification message- Throws:
NotificationException- if an error occurs while sending the notification
-
doCreateMessage
Description copied from class:NotificationSenderCreates the notification message to send.- Specified by:
doCreateMessagein classNotificationSender<EmailSender.EmailMessage>- Parameters:
templateName- the name of the template to use for the notificationpayload- the payload to include in the notification- Returns:
- the notification message
-
setFrom
-
setTo
-