public abstract class MailMessage extends Object
Modifier and Type | Field and Description |
---|---|
static String |
ACTIVATION_LINK_PREFIX
Holds the relative path to the user management section of administration area
|
Constructor and Description |
---|
MailMessage(String messageKey,
Locale locale,
Collection<User> recipients)
Construct a new message.
|
MailMessage(String messageKey,
Locale locale,
User... recipients)
Construct a new message.
|
MailMessage(String messageKey,
Map<String,String> templatePlaceholderMessageKeys,
Locale locale,
Collection<User> recipients)
Construct a new message.
|
MailMessage(String messageKey,
Map<String,String> templatePlaceholderMessageKeys,
Locale locale,
User... recipients)
Construct a new message.
|
Modifier and Type | Method and Description |
---|---|
void |
addBcc(User user)
Add a recipient of the email.
|
void |
addCc(User user)
Add a recipient of the email.
|
void |
addTo(String emailAddress)
Add a recipient of the email.
|
void |
addTo(String emailAddress,
String personalName)
Add a recipient of the email.
|
void |
addTo(User user)
Add a recipient of the email.
|
Collection<User> |
getBcc() |
Collection<User> |
getCc() |
String |
getContentTemplate() |
String |
getContentTemplateId() |
String |
getFromAddress()
Get the email address of the sender.
If no address has been set the configured address of the Communote installation will be returned. |
String |
getFromAddressName()
Get the personal name of the sender.
|
Map<String,Object> |
getGlobalModel()
Model of key-value pairs with common data useful for all mail messages.
|
Locale |
getLocale() |
String |
getMessageIdentifier()
Returns an identifier of the message which can be used in the Message-ID header.
|
String |
getReplyToAddress()
Returns a string holding the email address to be used in the "reply-to" header.
|
String |
getReplyToAddressName()
Returns the personal name to be used in the "reply-to" header field.
|
String |
getSubjectTemplate() |
String |
getSubjectTemplateId() |
Collection<User> |
getTo() |
Collection<String> |
getToAddresses() |
String |
getToAddressPersonalName(String emailAddress)
Return a personal name which was added with an email address by invoking
addTo(String, String) . |
boolean |
isHtmlMail()
States whether the underlying mail content template produces an HTML mail or not.
|
boolean |
isInsertRecipientPersonalName() |
abstract void |
prepareModel(Map<String,Object> model)
Prepare a model of key-value pairs which will be passed to the template engine when the
content and subject templates should be rendered.
|
void |
setFromAddress(String fromAddress)
Set the email address of sender.
Note: be careful when setting an address because the domain part of the address should normally not leave the domain of the outgoing email server. |
void |
setFromAddressName(String fromAddressName)
Set the personal name of the sender.
|
void |
setInsertRecipientPersonalName(boolean insertRecipientPersonalName)
Define whether the personal name (first name, last name and salutation if available) of a
recipient should be added to the TO, CC or BCC headers.
|
public static final String ACTIVATION_LINK_PREFIX
public MailMessage(String messageKey, Locale locale, User... recipients)
ResourceBundleManager
.messageKey
- Key of the message to get from the ResourceBundleManager
and use as
content template. The key will be returned by
getContentTemplateId()
. The key of the message to use as the
subject template is derived from the messageKey by appending .subject
to it.locale
- the locale to use when getting the templates from the
ResourceBundleManager
recipients
- A list of recipients of this message. The email addresses will be added to the TO
header.public MailMessage(String messageKey, Locale locale, Collection<User> recipients)
ResourceBundleManager
.messageKey
- Key of the message to get from the ResourceBundleManager
and use as
content template. The key will be returned by
getContentTemplateId()
. The key of the message to use as the
subject template is derived from the messageKey by appending .subject
to it.locale
- the locale to use when getting the templates from the
ResourceBundleManager
recipients
- A list of recipients of this message. The email addresses will be added to the TO
header.public MailMessage(String messageKey, Map<String,String> templatePlaceholderMessageKeys, Locale locale, User... recipients)
ResourceBundleManager
.messageKey
- Key of the message to get from the ResourceBundleManager
and use as
content template. The key will be returned by
getContentTemplateId()
. The key of the message to use as the
subject template is derived from the messageKey by appending .subject
to it.templatePlaceholderMessageKeys
- A mapping of placeholders to message keys, which will be replaced within the
template with the loaded message. Use it in the template @@placeholder@@.locale
- the locale to use when getting the templates from the
ResourceBundleManager
recipients
- A list of recipients of this message. The email addresses will be added to the TO
header.public MailMessage(String messageKey, Map<String,String> templatePlaceholderMessageKeys, Locale locale, Collection<User> recipients)
ResourceBundleManager
.messageKey
- Key of the message to get from the ResourceBundleManager
and use as
content template. The key will be returned by
getContentTemplateId()
. The key of the message to use as the
subject template is derived from the messageKey by appending .subject
to it.templatePlaceholderMessageKeys
- A mapping of placeholders to message keys, which will be replaced within the
template with the loaded message. Use it in the template @@placeholder@@.locale
- the locale to use when getting the templates from the
ResourceBundleManager
recipients
- A list of recipients of this message. The email addresses will be added to the TO
header.public void addBcc(User user)
user
- the user to send the mail topublic void addCc(User user)
user
- the user to send the mail topublic void addTo(User user)
user
- the user to send the mail topublic void addTo(String emailAddress)
emailAddress
- the email address of the recipientpublic void addTo(String emailAddress, String personalName)
emailAddress
- the email address of the recipientpersonalName
- the personal name to add to the TO header.public Collection<User> getBcc()
public Collection<User> getCc()
public String getContentTemplate()
public String getContentTemplateId()
public String getFromAddress()
public String getFromAddressName()
public Map<String,Object> getGlobalModel()
prepareModel(Map)
where it can be extended with specific data before
handing it over to the template rendering engine.public Locale getLocale()
public String getMessageIdentifier()
public String getReplyToAddress()
public String getReplyToAddressName()
public String getSubjectTemplate()
public String getSubjectTemplateId()
public Collection<User> getTo()
public Collection<String> getToAddresses()
getTo()
, instead only the addresses added with addTo(String)
or
addTo(String, String)
are returned.public String getToAddressPersonalName(String emailAddress)
addTo(String, String)
.emailAddress
- the email address for which the personal name should be returnedpublic boolean isHtmlMail()
public boolean isInsertRecipientPersonalName()
public abstract void prepareModel(Map<String,Object> model)
model
- The model to prepare. It will be initialized with the settings returned by
getGlobalModel()
.public void setFromAddress(String fromAddress)
fromAddress
- the email address to be used in From headerpublic void setFromAddressName(String fromAddressName)
fromAddressName
- the name of the sender to be used in the From headerpublic void setInsertRecipientPersonalName(boolean insertRecipientPersonalName)
insertRecipientPersonalName
- true to insert the personal name, false otherwiseCopyright © 2019 Communote team. All rights reserved.