public final class MailSender extends Object
MailSender
provides features to send mails.Constructor and Description |
---|
MailSender(MailAccount account)
Create a new
MailSender with the given account. |
Modifier and Type | Method and Description |
---|---|
MailBuilder |
compose()
Compose a new mail message.
|
void |
send(Message message)
Send a mail message.
|
void |
send(String subject,
String text,
String... recipients)
Send a simple text message to the given recipients.
For better options, use compose() method to compose a message
using MailBuilder which can be retrieved or sent directly with
MailBuilder.build() or MailBuilder.send() methods. |
public MailSender(MailAccount account)
MailSender
with the given account.account
- the account to usepublic MailBuilder compose()
MailBuilder
instance.public void send(Message message) throws MessagingException
message
- the message to sentMessagingException
- if the message could not be sentTransport.send(Message)
public void send(String subject, String text, String... recipients) throws MessagingException
compose()
method to compose a message
using MailBuilder
which can be retrieved or sent directly with
MailBuilder.build()
or MailBuilder.send()
methods.subject
- the message subjecttext
- the message textrecipients
- list of recipientsMessagingException
- if the message could not be sent