Package io.jmix.email
Interface Emailer
- All Known Implementing Classes:
- EmailerImpl
public interface Emailer
Provides application with emailing functionality.
 
Sending email can be synchronous (caller's thread is blocked until email is delivered to SMTP server) or asynchronous (email is persisted in a DB queue and sent later by scheduled task).
In order to send emails asynchronously, you should register a scheduled task that periodically invokes
Sending email can be synchronous (caller's thread is blocked until email is delivered to SMTP server) or asynchronous (email is persisted in a DB queue and sent later by scheduled task).
In order to send emails asynchronously, you should register a scheduled task that periodically invokes
processQueuedEmails() method.- 
Method SummaryModifier and TypeMethodDescriptionSend emails added to the queue.voidSend email synchronously.voidsendEmail(String address, String subject, String body, String bodyContentType, Boolean important, EmailAttachment... attachment) Send email synchronously.sendEmailAsync(EmailInfo info) Send email asynchronously.sendEmailAsync(EmailInfo info, Integer attemptsLimit, Date deadline) Send email asynchronously, with limited number of attempts.
- 
Method Details- 
sendEmailvoid sendEmail(String address, String subject, String body, String bodyContentType, Boolean important, EmailAttachment... attachment) throws EmailException Send email synchronously.- Parameters:
- address- comma or semicolon separated list of addresses
- subject- email subject
- body- email body
- bodyContentType- email body like "text/plain; charset=UTF-8" or "text/html; charset=UTF-8", etc
- attachment- email attachments
- Throws:
- EmailException- in case of any errors
 
- 
sendEmailSend email synchronously.- Parameters:
- info- email details
- Throws:
- EmailException- in case of any errors
 
- 
sendEmailAsyncSendingMessage sendEmailAsync(EmailInfo info, @Nullable Integer attemptsLimit, @Nullable Date deadline) Send email asynchronously, with limited number of attempts.- Parameters:
- info- email details
- attemptsLimit- count of attempts to send (1 attempt per scheduler tick). If not specified,- EmailerProperties.getDefaultSendingAttemptsLimit()is used
- deadline- 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.NOT_SENT
- Returns:
- created SendingMessage
 
- 
sendEmailAsyncSend email asynchronously.This method creates a SendingMessage, saves it to the database and returns immediately. The actual sending is performed by theprocessQueuedEmails()method which should be invoked by a scheduled task.- Parameters:
- info- email details
- Returns:
- created SendingMessage
 
- 
processQueuedEmailsString processQueuedEmails()Send emails added to the queue.This method should be called periodically from a scheduled task. - Returns:
- short message describing how many emails were sent, or error message
 
 
-