Package com.axelor.mail
Class MailSender
java.lang.Object
com.axelor.mail.MailSender
The
MailSender
provides features to send mails.-
Constructor Summary
ConstructorsConstructorDescriptionMailSender
(MailAccount account) Create a newMailSender
with the given account. -
Method Summary
Modifier and TypeMethodDescriptioncompose()
Compose a new mail message.void
send
(jakarta.mail.Message message) Send a mail message.void
Send a simple text message to the given recipients.
For better options, usecompose()
method to compose a message usingMailBuilder
which can be retrieved or sent directly withMailBuilder.build()
orMailBuilder.send()
methods.
-
Constructor Details
-
MailSender
Create a newMailSender
with the given account.- Parameters:
account
- the account to use
-
-
Method Details
-
compose
Compose a new mail message.- Returns:
- a
MailBuilder
instance.
-
send
public void send(jakarta.mail.Message message) throws jakarta.mail.MessagingException Send a mail message.- Parameters:
message
- the message to sent- Throws:
jakarta.mail.MessagingException
- if the message could not be sent- See Also:
-
send
public void send(String subject, String text, String... recipients) throws jakarta.mail.MessagingException Send a simple text message to the given recipients.
For better options, usecompose()
method to compose a message usingMailBuilder
which can be retrieved or sent directly withMailBuilder.build()
orMailBuilder.send()
methods.- Parameters:
subject
- the message subjecttext
- the message textrecipients
- list of recipients- Throws:
jakarta.mail.MessagingException
- if the message could not be sent
-