Package org.silverpeas.core.mail
Class MailSending
- java.lang.Object
-
- org.silverpeas.core.mail.MailSending
-
public class MailSending extends Object
Handles easily the send of an email. It deals with centralized mechanism that ensures a synchronized use of mail services (SMTP server connexion for example).- Author:
- Yohann Chastagnier
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static MailSending
from(MailAddress senderEmail)
Gets a new instance ofMailSending
by specifying the email of the sender.MailSending
oneMailPerReceiver()
One email sent by receiver instead of one email for all receivers.void
send()
Performs sending of the mail.void
sendSynchronously()
Performs sending of the mail synchronously.MailSending
setReplyToRequired()
Indicates that the reply to field of the mail must be set.MailSending
to(MailAddress receiverMailAddress)
Permits to specify the receiver of the mail.MailSending
to(ReceiverMailAddressSet receiverMailAddressSet)
Permits to specify the receiver of the mail.MailSending
withContent(String content)
Permits to specify the HTML content as String of the mail.MailSending
withContent(javax.mail.Multipart content)
Permits to specify the content asMultipart
of the mail.MailSending
withContent(MailContent content)
Permits to specify the content asMailContent
of the mail.MailSending
withSubject(String subject)
Permits to specify the subject of the mail.MailSending
withTextContent(String content)
Permits to specify the text content as String of the mail.
-
-
-
Method Detail
-
from
public static MailSending from(MailAddress senderEmail)
Gets a new instance ofMailSending
by specifying the email of the sender.- Parameters:
senderEmail
- the email of the sender. This email can be changed just before the send in case it is a not authorized one (seeMailUtil.getAuthorizedEmailAddress(String, String)
).- Returns:
- the new instance of
MailSending
.
-
to
public MailSending to(MailAddress receiverMailAddress)
Permits to specify the receiver of the mail.- Parameters:
receiverMailAddress
- the email of the receiver.- Returns:
- the completed instance of
MailSending
.
-
to
public MailSending to(ReceiverMailAddressSet receiverMailAddressSet)
Permits to specify the receiver of the mail.- Parameters:
receiverMailAddressSet
- the emails of the receivers.- Returns:
- the completed instance of
MailSending
.
-
withSubject
public MailSending withSubject(String subject)
Permits to specify the subject of the mail.- Parameters:
subject
- the subject.- Returns:
- the completed instance of
MailSending
.
-
withContent
public MailSending withContent(String content)
Permits to specify the HTML content as String of the mail.- Parameters:
content
- the content as String.- Returns:
- the completed instance of
MailSending
.
-
withTextContent
public MailSending withTextContent(String content)
Permits to specify the text content as String of the mail. If the string content contains<html>
TAG, then it will be considered as an HTML one, in all cases.- Parameters:
content
- the content as String.- Returns:
- the completed instance of
MailSending
.
-
withContent
public MailSending withContent(javax.mail.Multipart content)
Permits to specify the content asMultipart
of the mail.- Parameters:
content
- the content asMultipart
.- Returns:
- the completed instance of
MailSending
.
-
withContent
public MailSending withContent(MailContent content)
Permits to specify the content asMailContent
of the mail.- Parameters:
content
- the content asMailContent
.- Returns:
- the completed instance of
MailSending
.
-
setReplyToRequired
public MailSending setReplyToRequired()
Indicates that the reply to field of the mail must be set.- Returns:
- the completed instance of
MailSending
.
-
oneMailPerReceiver
public MailSending oneMailPerReceiver()
One email sent by receiver instead of one email for all receivers.- Returns:
- the completed instance of
MailSending
.
-
send
public void send()
Performs sending of the mail. This will be executed into a Threaded mechanism.
-
sendSynchronously
public void sendSynchronously()
Performs sending of the mail synchronously. So the caller wait for the end of the sending treatment before to continue its processing.
-
-