|
xmlBlaster 2.2.0 client API | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object javax.mail.Authenticator org.xmlBlaster.util.protocol.email.SmtpClient
public class SmtpClient
This class sends outgoing emails.
Developer note: Please don't use log.severe() or log.warning() to avoid recursion for logging-notification mails.
Field Summary | |
---|---|
static java.lang.String |
OBJECTENTRY_KEY
|
Constructor Summary | |
---|---|
SmtpClient()
Called from runlevel manager on server side. |
Method Summary | |
---|---|
int |
getAsyncSendQueueSizeMax()
|
java.lang.String |
getEnvPrefix()
The command line key prefix |
javax.mail.Message |
getMessage()
|
javax.mail.PasswordAuthentication |
getPasswordAuthentication()
Used by Authenticator to access user name and password |
java.lang.String |
getProtocolId()
Access the xmlBlaster internal name of the protocol driver. |
javax.mail.Session |
getSession()
Access the mailing session. |
static SmtpClient |
getSmtpClient(Global glob,
I_PluginConfig pluginConfig)
The SmtpClient is a singleton in the Global scope. |
int |
getSmtpConnectionTimeout()
mail.smtp.connectiontimeout Socket connection timeout value in milliseconds. |
int |
getSmtpIoTimeout()
mail.smtp.timeout Socket I/O timeout value in milliseconds. |
java.lang.String |
getSmtpUrl()
Access the SMTP access uri, for example "smtp://aUser:mypassword@mySmtpHost.org:25" |
java.lang.String |
getType()
Enforced by I_Plugin |
java.lang.String |
getUsageUrl()
|
java.lang.String |
getUser()
|
java.lang.String |
getVersion()
Enforced by I_Plugin |
void |
init(Global glob,
PluginInfo pluginInfo)
This method is called by the PluginManager (enforced by I_Plugin). |
boolean |
isAddExpiresHeader()
If the message to send has an expiry date and this addExpiresHeader=true we send an 'Expires:' header in the email (Expiry Date Indication). |
boolean |
isAsyncSendQueueBlockOnOverflow()
|
boolean |
isBreakLongMessageIdLine()
Defaults to false. |
boolean |
isContentForceBase64()
Force the MsgUnit attachment to always be base64 encoded. |
boolean |
isMessageIdForceBase64()
|
static void |
main(java.lang.String[] args)
Standalone usage example:
java -Dmail.debug=true -Dmail.smtp.url=smtp://xmlBlaster:xmlBlaster@localhost:25 org.xmlBlaster.util.protocol.email.SmtpClient -from xmlBlaster@localhost -to xmlBlaster@localhost -expires +5000
The output is like |
void |
send(javax.mail.Message message)
Send a ready prepared message. |
void |
sendEmail(EmailData emailData)
|
void |
sendEmail(EmailData emailData,
java.lang.String msgIdFileName)
|
void |
sendEmail(javax.mail.internet.InternetAddress from,
javax.mail.internet.InternetAddress to,
java.lang.String subject,
java.lang.String attachmentName,
byte[] attachment,
java.lang.String attachmentName2,
java.lang.String attachment2,
java.lang.String encoding)
|
void |
sendEmail(javax.mail.internet.InternetAddress from,
javax.mail.internet.InternetAddress to,
java.lang.String subject,
java.lang.String body,
java.lang.String encoding)
|
void |
sendEmail(java.lang.String from,
java.lang.String to,
java.lang.String subject,
java.lang.String body)
|
void |
sendEmail(java.lang.String from,
java.lang.String to,
java.lang.String subject,
java.lang.String body,
java.lang.String encoding)
|
void |
sendEmailAsync(EmailData emailData)
|
void |
sendEmailSync(EmailData emailData,
java.lang.String msgIdFileName)
Send a mail. |
java.lang.String |
sendTestEmail(java.lang.String to,
java.lang.String from)
JMX |
void |
setAddExpiresHeader(boolean addExpiresHeader)
Add 'Expires:' email header. |
void |
setAsyncSendQueueBlockOnOverflow(boolean asyncSendQueueBlockOnOverflow)
|
void |
setBreakLongMessageIdLine(boolean breakLongMessageIdLine)
Defaults to false. |
void |
setContentForceBase64(boolean contentForceBase64)
Setting this to true we can force the MsgUnit attachment to always be base64 encoded. |
void |
setMessageIdForceBase64(boolean messageIdForceBase64)
Setting this to true we can force the messageId attachment to always be base64 encoded. |
void |
setSessionProperties(java.util.Properties props,
Global glob,
I_PluginConfig pluginConfig)
Set session properties and create a session. |
void |
setSmtpUrl(java.lang.String uri)
|
void |
setUsageUrl(java.lang.String url)
|
void |
shutdown()
Cleans up the resource. |
java.lang.String |
usage()
|
Methods inherited from class javax.mail.Authenticator |
---|
getDefaultUserName, getRequestingPort, getRequestingPrompt, getRequestingProtocol, getRequestingSite |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final java.lang.String OBJECTENTRY_KEY
Constructor Detail |
---|
public SmtpClient()
Method Detail |
---|
public java.lang.String getUser()
public static SmtpClient getSmtpClient(Global glob, I_PluginConfig pluginConfig) throws XmlBlasterException
glob
- pluginInfo
-
XmlBlasterException
public java.lang.String getProtocolId()
public java.lang.String getType()
getType
in interface I_Plugin
public java.lang.String getEnvPrefix()
public java.lang.String getVersion()
getVersion
in interface I_Plugin
public void init(Global glob, PluginInfo pluginInfo) throws XmlBlasterException
init
in interface I_Plugin
XmlBlasterException
I_Plugin.init(org.xmlBlaster.util.Global,org.xmlBlaster.util.plugin.PluginInfo)
public javax.mail.PasswordAuthentication getPasswordAuthentication()
getPasswordAuthentication
in class javax.mail.Authenticator
public void setSessionProperties(java.util.Properties props, Global glob, I_PluginConfig pluginConfig) throws XmlBlasterException
Example settings:
Properties props = System.getProperties(); props.put("mail.debug", "true"); props.put("mail.smtp.url", "smtp://demo:secret@localhost:2525");
If a property is not found System.getProperty() is consulted.
XmlBlasterException
public void sendEmailAsync(EmailData emailData) throws XmlBlasterException
XmlBlasterException
public javax.mail.Session getSession()
public javax.mail.Message getMessage()
public void send(javax.mail.Message message) throws javax.mail.MessagingException
Usually you choose the convenience method sendEmail()
javax.mail.MessagingException
public void sendEmail(java.lang.String from, java.lang.String to, java.lang.String subject, java.lang.String body) throws javax.mail.internet.AddressException, javax.mail.MessagingException
javax.mail.internet.AddressException
javax.mail.MessagingException
public void sendEmail(java.lang.String from, java.lang.String to, java.lang.String subject, java.lang.String body, java.lang.String encoding) throws javax.mail.internet.AddressException, javax.mail.MessagingException
javax.mail.internet.AddressException
javax.mail.MessagingException
public void sendEmail(javax.mail.internet.InternetAddress from, javax.mail.internet.InternetAddress to, java.lang.String subject, java.lang.String body, java.lang.String encoding) throws javax.mail.internet.AddressException, javax.mail.MessagingException
body
- Is assumed to be of mime type "text/plain"encoding
- (charset) for example "UTF-8", will set the mail header:
Content-Type: text/plain; charset=UTF-8
javax.mail.internet.AddressException
javax.mail.MessagingException
public void sendEmail(javax.mail.internet.InternetAddress from, javax.mail.internet.InternetAddress to, java.lang.String subject, java.lang.String attachmentName, byte[] attachment, java.lang.String attachmentName2, java.lang.String attachment2, java.lang.String encoding) throws XmlBlasterException
attachmentName2
- If not null this second attachment is added as "text/plain"encoding
- For example "UTF-8"
XmlBlasterException
public java.lang.String sendTestEmail(java.lang.String to, java.lang.String from)
sendTestEmail
in interface SmtpClientMBean
to
- For example "demo@localhost"from
- For example "xmlBlaster@localhost"
public void sendEmail(EmailData emailData) throws XmlBlasterException
XmlBlasterException
public void sendEmail(EmailData emailData, java.lang.String msgIdFileName) throws XmlBlasterException
XmlBlasterException
public void sendEmailSync(EmailData emailData, java.lang.String msgIdFileName) throws XmlBlasterException
emailData
- Container holding the message to send
XmlBlasterException
public void shutdown()
I_Plugin
shutdown
in interface I_Plugin
public java.lang.String getSmtpUrl()
I_AdminSmtpClient
getSmtpUrl
in interface I_AdminSmtpClient
public void setSmtpUrl(java.lang.String uri)
setSmtpUrl
in interface I_AdminSmtpClient
uri
- For example "smtp://aUser:mypassword@mySmtpHost.org:25"public java.lang.String usage()
usage
in interface I_AdminUsage
public java.lang.String getUsageUrl()
getUsageUrl
in interface I_AdminUsage
public void setUsageUrl(java.lang.String url)
setUsageUrl
in interface I_AdminUsage
public boolean isContentForceBase64()
I_AdminSmtpClient
isContentForceBase64
in interface I_AdminSmtpClient
public void setContentForceBase64(boolean contentForceBase64)
I_AdminSmtpClient
setContentForceBase64
in interface I_AdminSmtpClient
contentForceBase64
- The contentForceBase64 to set.public boolean isMessageIdForceBase64()
isMessageIdForceBase64
in interface I_AdminSmtpClient
public void setMessageIdForceBase64(boolean messageIdForceBase64)
I_AdminSmtpClient
setMessageIdForceBase64
in interface I_AdminSmtpClient
messageIdForceBase64
- The messageIdForceBase64 to set.public static void main(java.lang.String[] args)
java -Dmail.debug=true -Dmail.smtp.url=smtp://xmlBlaster:xmlBlaster@localhost:25 org.xmlBlaster.util.protocol.email.SmtpClient -from xmlBlaster@localhost -to xmlBlaster@localhost -expires +5000
The output is like
Return-Path:Received: from localhost ([127.0.0.1]) by noty (JAMES SMTP Server 2.2.0) with SMTP ID 501 for ; Tue, 21 Feb 2006 10:54:58 +0100 (CET) Message-ID: <13748088.01140515698827.JavaMail.xmlBlaster@noty> Date: Tue, 21 Feb 2006 10:54:58 +0100 (CET) From: blue@localhost To: blue@localhost Subject: Hi from java MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Expires: Tue, 21 Feb 2006 10:55:00 +0100 (CET) Some body text
for other properties
public boolean isAddExpiresHeader()
I_AdminSmtpClient
isAddExpiresHeader
in interface I_AdminSmtpClient
http://www.faqs.org/rfcs/rfc2156.html
public void setAddExpiresHeader(boolean addExpiresHeader)
I_AdminSmtpClient
setAddExpiresHeader
in interface I_AdminSmtpClient
addExpiresHeader
- The addExpiresHeader to set.http://www.faqs.org/rfcs/rfc2156.html
public boolean isBreakLongMessageIdLine()
I_AdminSmtpClient
isBreakLongMessageIdLine
in interface I_AdminSmtpClient
public void setBreakLongMessageIdLine(boolean breakLongMessageIdLine)
I_AdminSmtpClient
setBreakLongMessageIdLine
in interface I_AdminSmtpClient
breakLongMessageIdLine
- The breakLongMessageIdLine to set.public int getSmtpIoTimeout()
I_AdminSmtpClient
getSmtpIoTimeout
in interface I_AdminSmtpClient
public int getSmtpConnectionTimeout()
I_AdminSmtpClient
getSmtpConnectionTimeout
in interface I_AdminSmtpClient
public int getAsyncSendQueueSizeMax()
getAsyncSendQueueSizeMax
in interface I_AdminSmtpClient
public boolean isAsyncSendQueueBlockOnOverflow()
isAsyncSendQueueBlockOnOverflow
in interface I_AdminSmtpClient
public void setAsyncSendQueueBlockOnOverflow(boolean asyncSendQueueBlockOnOverflow)
setAsyncSendQueueBlockOnOverflow
in interface I_AdminSmtpClient
asyncSendQueueBlockOnOverflow
- the asyncSendQueueBlockOnOverflow to set
|
xmlBlaster 2.2.0 client API | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |