Package io.jmix.email.impl
Class EmailerImpl
java.lang.Object
io.jmix.email.impl.EmailerImpl
- All Implemented Interfaces:
Emailer
-
Field Summary
Modifier and TypeFieldDescriptionprotected org.springframework.context.ApplicationContext
protected SystemAuthenticator
protected AtomicInteger
protected EmailCleaner
protected EmailDataProvider
protected EmailerProperties
protected EmailSender
protected org.springframework.core.task.TaskExecutor
protected Metadata
protected MetadataTools
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionprotected SendingMessage
convertToSendingMessage
(EmailInfo info, Integer attemptsLimit, Date deadline) protected SendingMessage
createClone
(SendingMessage srcMessage) protected String
getContentBodyType
(SendingMessage sendingMessage) protected boolean
protected void
persistAndSendEmail
(EmailInfo emailInfo) protected SendingMessage
persistMessageIfPossible
(SendingMessage sendingMessage) protected void
prepareEmailInfo
(EmailInfo emailInfo) Send emails added to the queue.protected void
void
Send email synchronously.void
sendEmail
(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.protected String
protected void
sendSendingMessage
(SendingMessage sendingMessage) protected void
protected SendingAttachment
-
Field Details
-
emailerProperties
-
callCount
-
mailSendTaskExecutor
protected org.springframework.core.task.TaskExecutor mailSendTaskExecutor -
emailDataProvider
-
metadata
-
authenticator
-
emailSender
-
metadataTools
-
applicationContext
@Autowired protected org.springframework.context.ApplicationContext applicationContext -
emailCleaner
-
-
Constructor Details
-
EmailerImpl
public EmailerImpl()
-
-
Method Details
-
sendEmail
public void sendEmail(String address, String subject, String body, String bodyContentType, Boolean important, EmailAttachment... attachment) throws EmailException Description copied from interface:Emailer
Send email synchronously.- Specified by:
sendEmail
in interfaceEmailer
- Parameters:
address
- comma or semicolon separated list of addressessubject
- email subjectbody
- email bodybodyContentType
- email body like "text/plain; charset=UTF-8" or "text/html; charset=UTF-8", etcattachment
- email attachments- Throws:
EmailException
- in case of any errors
-
sendEmail
Description copied from interface:Emailer
Send email synchronously.- Specified by:
sendEmail
in interfaceEmailer
- Parameters:
info
- email details- Throws:
EmailException
- in case of any errors
-
sendEmailAsync
Description copied from interface:Emailer
Send email asynchronously.This method creates a
SendingMessage
, saves it to the database and returns immediately. The actual sending is performed by theEmailer.processQueuedEmails()
method which should be invoked by a scheduled task.- Specified by:
sendEmailAsync
in interfaceEmailer
- Parameters:
info
- email details- Returns:
- created
SendingMessage
-
sendEmailAsync
public SendingMessage sendEmailAsync(EmailInfo info, @Nullable Integer attemptsLimit, @Nullable Date deadline) Description copied from interface:Emailer
Send email asynchronously, with limited number of attempts.- Specified by:
sendEmailAsync
in interfaceEmailer
- Parameters:
info
- email detailsattemptsLimit
- count of attempts to send (1 attempt per scheduler tick). If not specified,EmailerProperties.getDefaultSendingAttemptsLimit()
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 toSendingStatus.NOT_SENT
- Returns:
- created
SendingMessage
-
prepareEmailInfo
-
convertToSendingMessage
protected SendingMessage convertToSendingMessage(EmailInfo info, @Nullable Integer attemptsLimit, @Nullable Date deadline) -
sendSendingMessage
-
persistAndSendEmail
- Throws:
EmailException
-
persistMessageIfPossible
-
createClone
-
processQueuedEmails
Description copied from interface:Emailer
Send emails added to the queue.This method should be called periodically from a scheduled task.
- Specified by:
processQueuedEmails
in interfaceEmailer
- Returns:
- short message describing how many emails were sent, or error message
-
sendQueuedEmails
-
submitExecutorTask
-
getContentBodyType
-
replaceRecipientIfNecessary
-
toSendingAttachment
-
isNeedToRetry
-