@Component(value="cuba_Emailer") public class Emailer extends java.lang.Object implements EmailerAPI
NAME
Constructor and Description |
---|
Emailer() |
Modifier and Type | Method and Description |
---|---|
java.lang.String |
loadContentText(SendingMessage sendingMessage)
Loads content text for given message.
|
void |
migrateAttachmentsToFileStorage(java.util.List<SendingAttachment> attachments)
Migrate list of existing email attachments to be stored in file storage, in a single transaction.
|
void |
migrateEmailsToFileStorage(java.util.List<SendingMessage> messages)
Migrate list of existing messages to be stored in file storage, in a single transaction.
|
java.lang.String |
processQueuedEmails()
Send emails added to the queue.
|
void |
sendEmail(EmailInfo info)
Send email synchronously.
|
void |
sendEmail(java.lang.String addresses,
java.lang.String caption,
java.lang.String body,
EmailAttachment... attachments)
Send email synchronously.
|
java.util.List<SendingMessage> |
sendEmailAsync(EmailInfo info)
Send email asynchronously.
|
java.util.List<SendingMessage> |
sendEmailAsync(EmailInfo info,
java.lang.Integer attemptsCount,
java.util.Date deadline)
Send email asynchronously, with limited number of attempts.
|
void |
setConfig(Configuration configuration) |
@Inject public void setConfig(Configuration configuration)
public void sendEmail(java.lang.String addresses, java.lang.String caption, java.lang.String body, EmailAttachment... attachments) throws EmailException
EmailerAPI
sendEmail
in interface EmailerAPI
addresses
- comma or semicolon separated list of addressescaption
- email subjectbody
- email bodyattachments
- email attachmentsEmailException
- in case of any errorspublic void sendEmail(EmailInfo info) throws EmailException
EmailerAPI
sendEmail
in interface EmailerAPI
info
- email detailsEmailException
- in case of any errorspublic java.util.List<SendingMessage> sendEmailAsync(EmailInfo info)
EmailerAPI
This method creates a list of SendingMessage
instances, saves it to the database and returns immediately.
The actual sending is performed by the EmailerAPI.processQueuedEmails()
method which should be invoked by a
scheduled task.
sendEmailAsync
in interface EmailerAPI
info
- email detailsSendingMessage
spublic java.util.List<SendingMessage> sendEmailAsync(EmailInfo info, java.lang.Integer attemptsCount, java.util.Date deadline)
EmailerAPI
sendEmailAsync
in interface EmailerAPI
info
- email detailsattemptsCount
- count of attempts to send (1 attempt per scheduler tick). If not specified,
EmailerConfig.getDefaultSendingAttemptsCount()
is useddeadline
- Emailer tries to send message till deadline.
If deadline has come and message has not been sent, status of this message is changed to
SendingStatus.NOTSENT
SendingMessage
spublic java.lang.String processQueuedEmails()
EmailerAPI
This method should be called periodically from a scheduled task.
processQueuedEmails
in interface EmailerAPI
public java.lang.String loadContentText(SendingMessage sendingMessage)
EmailerAPI
loadContentText
in interface EmailerAPI
public void migrateEmailsToFileStorage(java.util.List<SendingMessage> messages)
EmailerAPI
migrateEmailsToFileStorage
in interface EmailerAPI
public void migrateAttachmentsToFileStorage(java.util.List<SendingAttachment> attachments)
EmailerAPI
migrateAttachmentsToFileStorage
in interface EmailerAPI