|
Openfire 3.4.3 Javadoc | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.jivesoftware.util.EmailService
public class EmailService
A service to send email.
This class has a few factory methods you can use to return message objects or to add messages into a queue to be sent. Using these methods, you can send emails in the following couple of ways:
EmailService.sendMessage( "Joe Bloe", "jbloe@place.org", "Jane Doe", "jane@doe.com", "Hello...", "This is the body of the email...", null );or
Message message = EmailService.createMimeMessage(); // call setters on the message object // . // . // . emailService.sendMessage(message);
This class is configured with a set of Jive properties:
Method Summary | |
---|---|
javax.mail.internet.MimeMessage |
createMimeMessage()
Factory method to return a blank JavaMail message. |
String |
getHost()
Returns the SMTP host (e.g. |
static EmailService |
getInstance()
|
String |
getPassword()
Returns the password used to connect to the SMTP server. |
int |
getPort()
Returns the port number used when connecting to the SMTP server. |
String |
getUsername()
Returns the username used to connect to the SMTP server. |
boolean |
isDebugEnabled()
Returns true if SMTP debugging is enabled. |
boolean |
isSSLEnabled()
Returns true if SSL is enabled for SMTP connections. |
void |
sendMessage(javax.mail.internet.MimeMessage message)
Sends a JavaMail message. |
void |
sendMessage(String toName,
String toEmail,
String fromName,
String fromEmail,
String subject,
String textBody,
String htmlBody)
Sends a message, specifying all of its fields. |
void |
sendMessages(Collection<javax.mail.internet.MimeMessage> messages)
Send a collection of messages. |
void |
sendMessagesImmediately(Collection<javax.mail.internet.MimeMessage> messages)
Sends a collection of email messages. |
void |
setDebugEnabled(boolean debugEnabled)
Enables or disables SMTP transport layer debugging. |
void |
setHost(String host)
Sets the SMTP host (e.g. |
void |
setPassword(String password)
Sets the password that will be used when connecting to the SMTP server. |
void |
setPort(int port)
Sets the port number that will be used when connecting to the SMTP server. |
void |
setSSLEnabled(boolean sslEnabled)
Sets whether the SMTP connection is configured to use SSL or not. |
void |
setUsername(String username)
Sets the username that will be used when connecting to the SMTP server. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Method Detail |
---|
public static EmailService getInstance()
public javax.mail.internet.MimeMessage createMimeMessage()
public void sendMessage(javax.mail.internet.MimeMessage message)
createMimeMessage()
method.
message
- the message to send.public void sendMessages(Collection<javax.mail.internet.MimeMessage> messages)
createMimeMessage()
method.
messages
- a collection of the messages to send.public void sendMessage(String toName, String toEmail, String fromName, String fromEmail, String subject, String textBody, String htmlBody)
To have more advanced control over the message sent, use the
sendMessage(MimeMessage)
method.
Both a plain text and html body can be specified. If one of the values is null, only the other body type is sent. If both body values are set, a multi-part message will be sent. If parts of the message are invalid (ie, the toEmail is null) the message won't be sent.
toName
- the name of the recipient of this email.toEmail
- the email address of the recipient of this email.fromName
- the name of the sender of this email.fromEmail
- the email address of the sender of this email.subject
- the subject of the email.textBody
- plain text body of the email, which can be null if the
html body is not null.htmlBody
- html body of the email, which can be null if the text body
is not null.public void sendMessagesImmediately(Collection<javax.mail.internet.MimeMessage> messages) throws javax.mail.MessagingException
sendMessages(Collection)
in that messages are sent
before this method returns rather than queueing the messages to be sent later.
messages
- the messages to send.
javax.mail.MessagingException
- if an error occurs.public String getHost()
public void setHost(String host)
host
- the SMTP host.public int getPort()
public void setPort(int port)
port
- the SMTP port number.public String getUsername()
public void setUsername(String username)
username
- the SMTP username.public String getPassword()
public void setPassword(String password)
password
- the SMTP password.public boolean isDebugEnabled()
public void setDebugEnabled(boolean debugEnabled)
debugEnabled
- true if SMTP debugging should be enabled.public boolean isSSLEnabled()
public void setSSLEnabled(boolean sslEnabled)
sslEnabled
- true if ssl should be enabled, false otherwise.
|
Openfire 3.4.3 Javadoc | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |