@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
EmailerAPIsendEmail in interface EmailerAPIaddresses - comma or semicolon separated list of addressescaption - email subjectbody - email bodyattachments - email attachmentsEmailException - in case of any errorspublic void sendEmail(EmailInfo info) throws EmailException
EmailerAPIsendEmail in interface EmailerAPIinfo - 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 EmailerAPIinfo - email detailsSendingMessagespublic java.util.List<SendingMessage> sendEmailAsync(EmailInfo info, java.lang.Integer attemptsCount, java.util.Date deadline)
EmailerAPIsendEmailAsync in interface EmailerAPIinfo - 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.NOTSENTSendingMessagespublic java.lang.String processQueuedEmails()
EmailerAPIThis method should be called periodically from a scheduled task.
processQueuedEmails in interface EmailerAPIpublic java.lang.String loadContentText(SendingMessage sendingMessage)
EmailerAPIloadContentText in interface EmailerAPIpublic void migrateEmailsToFileStorage(java.util.List<SendingMessage> messages)
EmailerAPImigrateEmailsToFileStorage in interface EmailerAPIpublic void migrateAttachmentsToFileStorage(java.util.List<SendingAttachment> attachments)
EmailerAPImigrateAttachmentsToFileStorage in interface EmailerAPI