play.libs
Class Mail

java.lang.Object
  extended by play.libs.Mail

public class Mail
extends java.lang.Object

Mail utils


Nested Class Summary
static class Mail.Mock
           
static class Mail.SMTPAuthenticator
           
 
Field Summary
static boolean asynchronousSend
           
static javax.mail.Session session
           
 
Constructor Summary
Mail()
           
 
Method Summary
protected static javax.mail.internet.MimeMessage addHeaders(javax.mail.internet.MimeMessage msg, java.util.Map<java.lang.String,java.lang.String> headers)
           
static javax.mail.internet.MimeMessage buildMessage(java.lang.Object from, java.lang.Object replyTo, java.lang.Object[] recipients, java.lang.String subject, java.lang.String body, java.lang.String alternate, java.lang.String contentType, java.lang.Object... attachments)
          Original method from the 1.0 release.
static javax.mail.internet.MimeMessage buildMimeMessage(javax.mail.internet.InternetAddress from, javax.mail.internet.InternetAddress replyTo, javax.mail.internet.InternetAddress[] recipients, java.lang.String subject, java.lang.String body, java.lang.String alternate, java.lang.String contentType, java.lang.Object... attachments)
          Construct a MimeMessage
static javax.mail.internet.MimeMessage buildMimeMessage(javax.mail.internet.InternetAddress from, javax.mail.internet.InternetAddress replyTo, javax.mail.internet.InternetAddress[] recipients, java.lang.String subject, java.lang.String body, java.lang.String alternate, java.lang.String contentType, java.lang.String charset, java.util.Map<java.lang.String,java.lang.String> headers, java.lang.Object... attachments)
          Construct a MimeMessage
static javax.mail.internet.MimeMessage buildMimeMessage(java.lang.String from, java.lang.String replyTo, java.lang.String[] recipients, java.lang.String subject, java.lang.String body, java.lang.String alternate, java.lang.String contentType, java.lang.Object... attachments)
           
protected static javax.mail.Multipart getMultipart(java.lang.String body, java.lang.String alternate, java.lang.String contentType, java.lang.String charset)
           
static java.util.concurrent.Future<java.lang.Boolean> send(java.lang.Object from, java.lang.Object replyTo, java.lang.Object[] recipients, java.lang.String subject, java.lang.String body, java.lang.String alternate, java.lang.String contentType, java.lang.Object... attachments)
           
static java.util.concurrent.Future<java.lang.Boolean> send(java.lang.String from, java.lang.String[] recipients, java.lang.String subject, java.lang.String body)
          Send an email in text/plain format
static java.util.concurrent.Future<java.lang.Boolean> send(java.lang.String from, java.lang.String[] recipients, java.lang.String subject, java.lang.String body, javax.activation.DataSource... attachments)
          Send an email in text/plain
static java.util.concurrent.Future<java.lang.Boolean> send(java.lang.String from, java.lang.String[] recipients, java.lang.String subject, java.lang.String body, java.io.File... attachments)
          Send an email in text/plain
static java.util.concurrent.Future<java.lang.Boolean> send(java.lang.String from, java.lang.String replyTo, java.lang.String[] recipients, java.lang.String subject, java.lang.String body, java.lang.String alternate, java.lang.String contentType, javax.activation.DataSource... attachments)
          Send an email
static java.util.concurrent.Future<java.lang.Boolean> send(java.lang.String from, java.lang.String replyTo, java.lang.String[] recipients, java.lang.String subject, java.lang.String body, java.lang.String alternate, java.lang.String contentType, java.io.File... attachments)
          Send an email
static java.util.concurrent.Future<java.lang.Boolean> send(java.lang.String from, java.lang.String recipient, java.lang.String subject, java.lang.String body)
          Send an email in plain text
static java.util.concurrent.Future<java.lang.Boolean> send(java.lang.String from, java.lang.String recipient, java.lang.String subject, java.lang.String body, javax.activation.DataSource... attachments)
          Send an email in text/plain
static java.util.concurrent.Future<java.lang.Boolean> send(java.lang.String from, java.lang.String recipient, java.lang.String subject, java.lang.String body, java.io.File... attachments)
          Send an email in text/plain
static java.util.concurrent.Future<java.lang.Boolean> send(java.lang.String from, java.lang.String recipient, java.lang.String subject, java.lang.String body, java.lang.String alternate)
          Send an email in text/html with a text/plain alternative
static java.util.concurrent.Future<java.lang.Boolean> send(java.lang.String from, java.lang.String recipient, java.lang.String subject, java.lang.String body, java.lang.String alternate, javax.activation.DataSource... attachments)
          Send an email in text/html with a text/plain alternative and attachments
static java.util.concurrent.Future<java.lang.Boolean> send(java.lang.String from, java.lang.String recipient, java.lang.String subject, java.lang.String body, java.lang.String alternate, java.io.File... attachments)
          Send an email in text/html with a text/plain alternative and attachments
static java.util.concurrent.Future<java.lang.Boolean> sendEmail(java.lang.Object from, java.lang.Object replyTo, java.lang.Object[] recipients, java.lang.String subject, java.lang.String body, java.lang.String alternate, java.lang.String contentType, java.lang.String charset, java.util.Map<java.lang.String,java.lang.String> headers, java.lang.Object... attachments)
          Send an email
static java.util.concurrent.Future<java.lang.Boolean> sendMessage(javax.mail.Message msg)
          Send a JavaMail message
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

session

public static javax.mail.Session session

asynchronousSend

public static boolean asynchronousSend
Constructor Detail

Mail

public Mail()
Method Detail

send

public static java.util.concurrent.Future<java.lang.Boolean> send(java.lang.String from,
                                                                  java.lang.String recipient,
                                                                  java.lang.String subject,
                                                                  java.lang.String body)
Send an email in plain text

Parameters:
from - From address. Can be of the form xxx
recipient - To address. Can be of the form xxx
subject - Subject
body - Body

send

public static java.util.concurrent.Future<java.lang.Boolean> send(java.lang.String from,
                                                                  java.lang.String recipient,
                                                                  java.lang.String subject,
                                                                  java.lang.String body,
                                                                  java.lang.String alternate)
Send an email in text/html with a text/plain alternative

Parameters:
from - From address. Can be of the form xxx
recipient - To address. Can be of the form xxx
subject - Subject
body - text/html body content
alternate - text/plain alternative content (optional)

send

public static java.util.concurrent.Future<java.lang.Boolean> send(java.lang.String from,
                                                                  java.lang.String recipient,
                                                                  java.lang.String subject,
                                                                  java.lang.String body,
                                                                  java.lang.String alternate,
                                                                  java.io.File... attachments)
Send an email in text/html with a text/plain alternative and attachments

Parameters:
from - From address. Can be of the form xxx
recipient - To address. Can be of the form xxx
subject - Subject
body - text/html body content
alternate - text/plain alternative content (optional)
attachments - File attachments

send

public static java.util.concurrent.Future<java.lang.Boolean> send(java.lang.String from,
                                                                  java.lang.String recipient,
                                                                  java.lang.String subject,
                                                                  java.lang.String body,
                                                                  java.lang.String alternate,
                                                                  javax.activation.DataSource... attachments)
Send an email in text/html with a text/plain alternative and attachments

Parameters:
from - From address. Can be of the form xxx
recipient - To address. Can be of the form xxx
subject - Subject
body - text/html body content
alternate - text/plain alternative content (optional)
attachments - DataSource attachments

send

public static java.util.concurrent.Future<java.lang.Boolean> send(java.lang.String from,
                                                                  java.lang.String[] recipients,
                                                                  java.lang.String subject,
                                                                  java.lang.String body)
Send an email in text/plain format

Parameters:
from - From address. Can be of the form xxx
recipients - To addresses. Can be of the form xxx
subject - Subject
body - The text/plain body of the email

send

public static java.util.concurrent.Future<java.lang.Boolean> send(java.lang.String from,
                                                                  java.lang.String recipient,
                                                                  java.lang.String subject,
                                                                  java.lang.String body,
                                                                  java.io.File... attachments)
Send an email in text/plain

Parameters:
from - From address. Can be of the form xxx
recipient - To address. Can be of the form xxx
subject - Subject
body - plain/text body of the email
attachments - File attachments

send

public static java.util.concurrent.Future<java.lang.Boolean> send(java.lang.String from,
                                                                  java.lang.String recipient,
                                                                  java.lang.String subject,
                                                                  java.lang.String body,
                                                                  javax.activation.DataSource... attachments)
Send an email in text/plain

Parameters:
from - From address. Can be of the form xxx
recipient - To address. Can be of the form xxx
subject - Subject
body - plain/text body of the email
attachments - DataSource attachments

send

public static java.util.concurrent.Future<java.lang.Boolean> send(java.lang.String from,
                                                                  java.lang.String[] recipients,
                                                                  java.lang.String subject,
                                                                  java.lang.String body,
                                                                  java.io.File... attachments)
Send an email in text/plain

Parameters:
from - From address Can be of the form xxx
recipients - To addresses Can be of the form xxx
subject - Subject
body - Body
attachments - File attachments

send

public static java.util.concurrent.Future<java.lang.Boolean> send(java.lang.String from,
                                                                  java.lang.String[] recipients,
                                                                  java.lang.String subject,
                                                                  java.lang.String body,
                                                                  javax.activation.DataSource... attachments)
Send an email in text/plain

Parameters:
from - From address Can be of the form xxx
recipients - To addresses Can be of the form xxx
subject - Subject
body - Body
attachments - DataSource attachments

send

public static java.util.concurrent.Future<java.lang.Boolean> send(java.lang.String from,
                                                                  java.lang.String replyTo,
                                                                  java.lang.String[] recipients,
                                                                  java.lang.String subject,
                                                                  java.lang.String body,
                                                                  java.lang.String alternate,
                                                                  java.lang.String contentType,
                                                                  java.io.File... attachments)
Send an email

Parameters:
from - From address. Can be of the form xxx
replyTo - ReplyTo address Can be of the form xxx
recipients - To addresses
subject - Subject
body - body of the email
alternate - text/plain body (optional). This parameter is ignored if contentType is set to text/plain or is null.
contentType - The content type of the body (text/plain or text/html)
attachments - File attachments

send

public static java.util.concurrent.Future<java.lang.Boolean> send(java.lang.String from,
                                                                  java.lang.String replyTo,
                                                                  java.lang.String[] recipients,
                                                                  java.lang.String subject,
                                                                  java.lang.String body,
                                                                  java.lang.String alternate,
                                                                  java.lang.String contentType,
                                                                  javax.activation.DataSource... attachments)
Send an email

Parameters:
from - From address. Can be of the form xxx
replyTo - ReplyTo address Can be of the form xxx
recipients - To addresses
subject - Subject
body - body of the email
alternate - text/plain body (optional). This parameter is ignored if contentType is set to text/plain or is null.
contentType - The content type of the body (text/plain or text/html)
attachments - DataSource attachments

send

public static java.util.concurrent.Future<java.lang.Boolean> send(java.lang.Object from,
                                                                  java.lang.Object replyTo,
                                                                  java.lang.Object[] recipients,
                                                                  java.lang.String subject,
                                                                  java.lang.String body,
                                                                  java.lang.String alternate,
                                                                  java.lang.String contentType,
                                                                  java.lang.Object... attachments)
Parameters:
from - From address a String or an InternetAddress
replyTo - ReplyTo address a String or an InternetAddress
recipients - To addresses an Array of String or/and InternetAddress
subject - Subject
body - body of the email
alternate - text/plain body (optional). This parameter is ignored if contentType is set to text/plain or is null.
contentType - The content type of the body (text/plain or text/html)
attachments - File attachments

sendEmail

public static java.util.concurrent.Future<java.lang.Boolean> sendEmail(java.lang.Object from,
                                                                       java.lang.Object replyTo,
                                                                       java.lang.Object[] recipients,
                                                                       java.lang.String subject,
                                                                       java.lang.String body,
                                                                       java.lang.String alternate,
                                                                       java.lang.String contentType,
                                                                       java.lang.String charset,
                                                                       java.util.Map<java.lang.String,java.lang.String> headers,
                                                                       java.lang.Object... attachments)
Send an email

Parameters:
from - From address a String or an InternetAddress
replyTo - ReplyTo address a String or an InternetAddress
recipients - To addresses an Array of String or/and InternetAddress
subject - Subject
body - body of the email
alternate - text/plain body (optional). This parameter is ignored if contentType is set to text/plain or is null.
contentType - The content type of the body (text/plain or text/html)
charset - The character set of the message (optional)
headers - The mail headers (optional)
attachments - File or DataSource attachments

buildMessage

public static javax.mail.internet.MimeMessage buildMessage(java.lang.Object from,
                                                           java.lang.Object replyTo,
                                                           java.lang.Object[] recipients,
                                                           java.lang.String subject,
                                                           java.lang.String body,
                                                           java.lang.String alternate,
                                                           java.lang.String contentType,
                                                           java.lang.Object... attachments)
                                                    throws javax.mail.MessagingException
Original method from the 1.0 release.

Parameters:
from - From address a String or an InternetAddress
replyTo - ReplyTo address a String or an InternetAddress
recipients - To addresses an Array of String or/and InternetAddress
subject -
body -
alternate -
contentType -
attachments -
Returns:
Throws:
javax.mail.MessagingException

buildMimeMessage

public static javax.mail.internet.MimeMessage buildMimeMessage(java.lang.String from,
                                                               java.lang.String replyTo,
                                                               java.lang.String[] recipients,
                                                               java.lang.String subject,
                                                               java.lang.String body,
                                                               java.lang.String alternate,
                                                               java.lang.String contentType,
                                                               java.lang.Object... attachments)
                                                        throws javax.mail.MessagingException
Parameters:
from -
replyTo -
recipients -
subject -
body -
alternate -
contentType -
attachments -
Returns:
Throws:
javax.mail.MessagingException

buildMimeMessage

public static javax.mail.internet.MimeMessage buildMimeMessage(javax.mail.internet.InternetAddress from,
                                                               javax.mail.internet.InternetAddress replyTo,
                                                               javax.mail.internet.InternetAddress[] recipients,
                                                               java.lang.String subject,
                                                               java.lang.String body,
                                                               java.lang.String alternate,
                                                               java.lang.String contentType,
                                                               java.lang.Object... attachments)
                                                        throws javax.mail.MessagingException
Construct a MimeMessage

Parameters:
from - From address
recipients - To addresses
subject - Subject
body - body of the email
alternate - text/plain body (optional). This parameter is ignored if contentType is set to text/plain or is null.
contentType - The content type of the body (text/plain or text/html) (optional)
attachments - File attachments
Throws:
javax.mail.MessagingException

buildMimeMessage

public static javax.mail.internet.MimeMessage buildMimeMessage(javax.mail.internet.InternetAddress from,
                                                               javax.mail.internet.InternetAddress replyTo,
                                                               javax.mail.internet.InternetAddress[] recipients,
                                                               java.lang.String subject,
                                                               java.lang.String body,
                                                               java.lang.String alternate,
                                                               java.lang.String contentType,
                                                               java.lang.String charset,
                                                               java.util.Map<java.lang.String,java.lang.String> headers,
                                                               java.lang.Object... attachments)
                                                        throws javax.mail.MessagingException
Construct a MimeMessage

Parameters:
from - From address
recipients - To addresses
subject - Subject
body - body of the email
alternate - text/plain body (optional). This parameter is ignored if contentType is set to text/plain or is null.
contentType - The content type of the body (text/plain or text/html) (optional)
charset - The character set of the message (optional)
headers - The mail headers (optional)
attachments - File or DataSource attachments
Throws:
javax.mail.MessagingException

addHeaders

protected static javax.mail.internet.MimeMessage addHeaders(javax.mail.internet.MimeMessage msg,
                                                            java.util.Map<java.lang.String,java.lang.String> headers)
                                                     throws javax.mail.MessagingException
Throws:
javax.mail.MessagingException

getMultipart

protected static javax.mail.Multipart getMultipart(java.lang.String body,
                                                   java.lang.String alternate,
                                                   java.lang.String contentType,
                                                   java.lang.String charset)
                                            throws javax.mail.MessagingException
Throws:
javax.mail.MessagingException

sendMessage

public static java.util.concurrent.Future<java.lang.Boolean> sendMessage(javax.mail.Message msg)
Send a JavaMail message

Parameters:
msg - A JavaMail message


Guillaume Bort & zenexity - Distributed under Apache 2 licence, without any warrantly