public class Mailer
extends java.lang.Object
Modifier and Type | Class and Description |
---|---|
static class |
Mailer.MimeContent |
static class |
Mailer.MimeType |
static class |
Mailer.Protocol |
Modifier and Type | Field and Description |
---|---|
static boolean |
debug
If true, the debug message will be output to console.
|
static java.lang.String |
DEFAULT_HOST |
static int |
DEFAULT_PORT |
static Mailer.Protocol |
DEFAULT_PROTOCOL
|
static java.lang.String |
SEPARATOR_EQUAL |
static java.lang.String |
SEPARATOR_SEMI_COLON |
Constructor and Description |
---|
Mailer()
Create a Mailer
with default host "", port 25 and protocol
DEFAULT_PROTOCOL ,
without Authentication (no need of user/password) |
Mailer(java.lang.String host,
int port,
Mailer.Protocol protocol)
Create a Mailer
with host, port and protocol,
without Authentication (no need of user/password)
|
Mailer(java.lang.String host,
int port,
Mailer.Protocol protocol,
java.lang.String user,
java.lang.String password)
Create a Mailer with Authentication (user/password) and host/port/protocol
|
Mailer(java.lang.String user,
java.lang.String password)
Create a Mailer
with default host "", port 25 and protocol
DEFAULT_PROTOCOL ,
with Authentication (user/password) |
Modifier and Type | Method and Description |
---|---|
static void |
addMessag(java.lang.String message,
Mailer.MimeType msg_type,
java.util.Map<java.lang.Integer,Mailer.MimeContent> contents) |
protected javax.mail.Session |
getSession()
Note: Before calling this method, we must call
#prepareProperties(String, String) and prepareProperties(String, int, Protocol) . |
static void |
handleAttachments(java.lang.String attachments,
java.util.Map<java.lang.String,java.lang.String> attachments_alias) |
static void |
handleRecipients(java.lang.String recipients,
java.util.List<java.lang.String> list) |
static void |
main(java.lang.String[] args) |
javax.mail.internet.MimeMessage |
prepareMimeMessage(java.util.List<java.lang.String> recipients,
java.lang.String subject)
Prepare the MimeMessage for sending.
|
protected javax.mail.internet.MimeMessage |
prepareMimeMessage(java.util.Map<javax.mail.Message.RecipientType,java.util.List<java.lang.String>> type_recipients,
java.lang.String subject)
Prepare the MimeMessage for sending.
|
protected static javax.mail.internet.MimeMessage |
prepareMimeMessage(javax.mail.Session session,
java.util.List<java.lang.String> recipients,
java.lang.String from,
java.lang.String subject) |
protected static javax.mail.internet.MimeMessage |
prepareMimeMessage(javax.mail.Session session,
java.util.Map<javax.mail.Message.RecipientType,java.util.List<java.lang.String>> type_recipients,
java.lang.String from,
java.lang.String subject) |
void |
send(java.util.List<java.lang.String> recipients,
java.lang.String subject,
java.util.Map<java.lang.Integer,Mailer.MimeContent> contents,
java.util.Map<java.lang.String,java.lang.String> attchments_alias)
Mail a set of objects, the content's type is defined by MimeType.
It will also send attachments provided by the last parameter 'attchments_alias'. |
void |
send(java.util.List<java.lang.String> recipients,
java.lang.String subject,
java.lang.Object body,
Mailer.MimeType type)
Mail object content, the content's type is defined by parameter format.
|
void |
send(java.util.List<java.lang.String> recipients,
java.lang.String subject,
java.lang.Object body,
Mailer.MimeType type,
java.util.List<java.lang.String> attachments)
Mail object, the content's type is defined by parameter format.
It will also send attachments provided by the last parameter 'attachments'. |
void |
send(java.util.List<java.lang.String> recipients,
java.lang.String subject,
java.lang.Object body,
Mailer.MimeType type,
java.util.Map<java.lang.String,java.lang.String> attchments_alias)
Mail an object, the content's type is defined by MimeType.
It will also send attachments provided by the last parameter 'attchments_alias'. |
void |
send(java.util.List<java.lang.String> recipients,
java.lang.String subject,
java.lang.Object body,
Mailer.MimeType type,
java.lang.String attachment)
Mail object, the content's type is defined by parameter format.
It will also send attachments provided by the last parameter 'attachment'. |
void |
send(java.util.List<java.lang.String> recipients,
java.lang.String subject,
java.lang.String body)
Mail text message.
|
void |
send(java.util.Map<javax.mail.Message.RecipientType,java.util.List<java.lang.String>> type_recipients,
java.lang.String subject,
java.util.Map<java.lang.Integer,Mailer.MimeContent> contents,
java.util.Map<java.lang.String,java.lang.String> attchments_alias)
Mail a set of objects, the content's type is defined by MimeType.
It will also send attachments provided by the last parameter 'attchments_alias'. |
protected void |
send(javax.mail.internet.MimeMessage message)
Before calling this method, the property "mail.transport.protocol" should be ready,
refer to
prepareProperties(String, int, Protocol) . |
void |
setSender(java.lang.String sender)
Set the mail sender.
|
public static java.lang.String SEPARATOR_SEMI_COLON
public static java.lang.String SEPARATOR_EQUAL
public static final java.lang.String DEFAULT_HOST
public static final int DEFAULT_PORT
public static final Mailer.Protocol DEFAULT_PROTOCOL
public static boolean debug
public Mailer() throws java.lang.Exception
DEFAULT_PROTOCOL
,
without Authentication (no need of user/password)java.lang.Exception
public Mailer(java.lang.String host, int port, Mailer.Protocol protocol) throws java.lang.Exception
host
- , String, the host name of the mail server.port
- , int, the port number the mailer service is listening to.protocol
- , Protocol, the mail service's protocoljava.lang.Exception
public Mailer(java.lang.String user, java.lang.String password) throws java.lang.Exception
DEFAULT_PROTOCOL
,
with Authentication (user/password)user
- , String, the user name used to login.password
- , String, the password of the user.java.lang.Exception
public Mailer(java.lang.String host, int port, Mailer.Protocol protocol, java.lang.String user, java.lang.String password) throws java.lang.Exception
host
- , String, the host name of the mail server.port
- , int, the port number the mailer service is listening to.protocol
- , Protocol, the mail service's protocoluser
- , String, the user name used to login.password
- , String, the password of the user.java.lang.Exception
protected javax.mail.Session getSession() throws java.lang.Exception
#prepareProperties(String, String)
and prepareProperties(String, int, Protocol)
.java.lang.Exception
prepareProperties(String, int, Protocol)
,
#prepareProperties(String, String)
public void setSender(java.lang.String sender)
sender
- public javax.mail.internet.MimeMessage prepareMimeMessage(java.util.List<java.lang.String> recipients, java.lang.String subject) throws java.lang.Exception
recipients
- , Listsubject
- , String, the mail's subjectjava.lang.Exception
send(List, String, String)
,
#send(List, String, String, MimeType)
,
#send(List, String, String, MimeType, String)
protected javax.mail.internet.MimeMessage prepareMimeMessage(java.util.Map<javax.mail.Message.RecipientType,java.util.List<java.lang.String>> type_recipients, java.lang.String subject) throws java.lang.Exception
type_recipients
- , Mapsubject
- , String, the mail's subjectjava.lang.Exception
send(List, String, String)
,
#send(List, String, String, MimeType)
,
#send(List, String, String, MimeType, String)
protected static javax.mail.internet.MimeMessage prepareMimeMessage(javax.mail.Session session, java.util.List<java.lang.String> recipients, java.lang.String from, java.lang.String subject) throws java.lang.Exception
java.lang.Exception
protected static javax.mail.internet.MimeMessage prepareMimeMessage(javax.mail.Session session, java.util.Map<javax.mail.Message.RecipientType,java.util.List<java.lang.String>> type_recipients, java.lang.String from, java.lang.String subject) throws java.lang.Exception
java.lang.Exception
protected void send(javax.mail.internet.MimeMessage message) throws SAFSException
prepareProperties(String, int, Protocol)
.message
- SAFSException
#prepareProperties(String, int, Protocol)}
,
prepareProperties(String, String, Protocol)
,
getSession()
public void send(java.util.List<java.lang.String> recipients, java.lang.String subject, java.lang.String body) throws SAFSException
recipients
- , Listsubject
- , String, the mail's subjectbody
- , String, the text message to mail.SAFSException
- if there is something wrongpublic void send(java.util.List<java.lang.String> recipients, java.lang.String subject, java.lang.Object body, Mailer.MimeType type) throws SAFSException
recipients
- , Listsubject
- , String, the mail's subjectbody
- , Object, the object to mail.type
- , the MimeType of the mail body.SAFSException
- if there is something wrongpublic void send(java.util.List<java.lang.String> recipients, java.lang.String subject, java.lang.Object body, Mailer.MimeType type, java.lang.String attachment) throws SAFSException
recipients
- , Listsubject
- , String, the mail's subjectbody
- , Object, the object to mail.type
- , the MimeType of the mail body.attachment
- , String, a full path file name to attachSAFSException
- if there is something wrongpublic void send(java.util.List<java.lang.String> recipients, java.lang.String subject, java.lang.Object body, Mailer.MimeType type, java.util.List<java.lang.String> attachments) throws SAFSException
recipients
- , Listsubject
- , String, the mail's subjectbody
- , Object, the object to mail.type
- , the MimeType of the mail body.attachments
- , ListSAFSException
- if there is something wrongpublic void send(java.util.List<java.lang.String> recipients, java.lang.String subject, java.lang.Object body, Mailer.MimeType type, java.util.Map<java.lang.String,java.lang.String> attchments_alias) throws SAFSException
recipients
- , Listsubject
- , String, the mail's subjectbody
- , Object, the object to mail.type
- , the MimeType of the mail body.attchments_alias
- , MapSAFSException
- if there is something wrongpublic void send(java.util.List<java.lang.String> recipients, java.lang.String subject, java.util.Map<java.lang.Integer,Mailer.MimeContent> contents, java.util.Map<java.lang.String,java.lang.String> attchments_alias) throws SAFSException
recipients
- , Listsubject
- , String, the mail's subjectcontents
- , Mapattchments_alias
- , MapSAFSException
- if there is something wrongpublic void send(java.util.Map<javax.mail.Message.RecipientType,java.util.List<java.lang.String>> type_recipients, java.lang.String subject, java.util.Map<java.lang.Integer,Mailer.MimeContent> contents, java.util.Map<java.lang.String,java.lang.String> attchments_alias) throws SAFSException
type_recipients
- , Mapsubject
- , String, the mail's subjectcontents
- , Mapattchments_alias
- , MapSAFSException
- if there is something wrongpublic static void handleRecipients(java.lang.String recipients, java.util.List<java.lang.String> list)
recipients
- ,String , semi-colon separated string, example user1@company1;user2@company2list
- (out), Listpublic static void handleAttachments(java.lang.String attachments, java.util.Map<java.lang.String,java.lang.String> attachments_alias)
attachments
- ,String , semi-colon separated string, example c:\folder\file.txt=alias.txt;d:\directory\compress.zip=compress.zip.unzipmeattachments_alias
- (out), Mappublic static void addMessag(java.lang.String message, Mailer.MimeType msg_type, java.util.Map<java.lang.Integer,Mailer.MimeContent> contents)
message
- , String, the message to sendmsg_type
- , MimeType, the message typecontents
- (out), Mappublic static void main(java.lang.String[] args)
Copyright © SAS Institute. All Rights Reserved.