org.silverpeas.mail
Class MailSending

java.lang.Object
  extended by org.silverpeas.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
static MailSending from(MailAddress senderEmail)
          Gets a new instance of MailSending by specifying the email of the sender.
 void send()
          Performs the send of the mail.
 void sendSynchronously()
          Performs the send 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(MailContent content)
          Permits to specify the content as MailContent of the mail.
 MailSending withContent(javax.mail.Multipart content)
          Permits to specify the content as Multipart of the mail.
 MailSending withContent(String content)
          Permits to specify the HTML content as String 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.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

from

public static MailSending from(MailAddress senderEmail)
Gets a new instance of MailSending 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 (see MailUtil.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 as Multipart of the mail.

Parameters:
content - the content as Multipart.
Returns:
the completed instance of MailSending.

withContent

public MailSending withContent(MailContent content)
Permits to specify the content as MailContent of the mail.

Parameters:
content - the content as MailContent.
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.

send

public void send()
Performs the send of the mail. This will be executed into a Threaded mechanism.


sendSynchronously

public void sendSynchronously()
Performs the send of the mail synchronously. So the caller wait for the end of the sending treatment before to continue its processing.



Copyright © 2016 Silverpeas. All Rights Reserved.