|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.norther.tammi.core.base.Adaptee org.norther.tammi.core.config.DefaultConfigurable org.norther.tammi.core.mail.DefaultMailer
public class DefaultMailer
The default implementation of Mailer. TODO: Test authentication TODO: Handle other content types and multipart messages TODO: Use event listeners to report unsent messages TODO: Support different providers by getting the transport object from the session
Nested Class Summary |
---|
Nested classes/interfaces inherited from class org.norther.tammi.core.config.DefaultConfigurable |
---|
DefaultConfigurable.Modified |
Field Summary |
---|
Fields inherited from class org.norther.tammi.core.base.Adaptee |
---|
ADAPTEE_NOTIF_DESCRIPTION, ADAPTEE_NOTIFICATIONS |
Fields inherited from interface org.norther.tammi.core.mail.Mailer |
---|
MAIL_DEBUG_PROPERTY, MAIL_FROM_PROPERTY, MAIL_HOST_PROPERTY, MAIL_MIME_ADDRESS_STRICT_PROPERTY, MAIL_MIME_CHARSET_PROPERTY, MAIL_PORT_PROPERTY, MAIL_PROPERTY_PREFIX, MAIL_TRANSPORT_PROTOCOL_PROPERTY, MAIL_USER_PROPERTY, MAILER_PASSWORD_PROPERTY, MAILER_PROPERTY_PREFIX, MAILER_X_MAILER_PROPERTY |
Constructor Summary | |
---|---|
DefaultMailer()
Constructs a new mail sender. |
Method Summary | |
---|---|
void |
applyServerURL(String server)
Applies the specified URL to the mail server configuration. |
boolean |
getDebug()
Gets debugging flag for JavaMail Session object. |
ObjectName |
getExecutorName()
Gets the the executor of this executable. |
javax.mail.internet.InternetAddress |
getFrom()
Gets the address of the current user. |
String |
getHost()
Gets the host name of the mail server. |
int |
getPort()
Gets the port number of the mail server. |
String |
getProtocol()
Gets the protocol for sending. |
String |
getServerURL()
Gets the mail server to be connected as an URL. |
String |
getUser()
Gets the username for connecting the mail server. |
boolean |
isStarted()
Checks whether the startable has been started. |
void |
run()
Runs in the background message thread that does actual send mail operation using JavaMail. |
void |
sendMail(javax.mail.internet.InternetAddress[] toAddress,
String subject,
String messageBody)
Sends a text-only mail message with minimal addressing information to specified addresses. |
void |
sendMail(javax.mail.internet.InternetAddress fromAddress,
javax.mail.internet.InternetAddress[] replyToAddress,
javax.mail.internet.InternetAddress senderAddress,
javax.mail.internet.InternetAddress[] toAddress,
javax.mail.internet.InternetAddress[] ccAddress,
javax.mail.internet.InternetAddress[] bccAddress,
String subject,
String messageBody)
Sends a text-only mail message with full addressing information. |
void |
sendMail(javax.mail.internet.InternetAddress fromAddress,
javax.mail.internet.InternetAddress[] replyToAddress,
javax.mail.internet.InternetAddress senderAddress,
javax.mail.internet.InternetAddress[] toAddress,
javax.mail.internet.InternetAddress[] ccAddress,
javax.mail.internet.InternetAddress[] bccAddress,
String subject,
String messageBody,
String encoding)
Sends an encoded text-only mail message with full addressing information. |
void |
sendMail(javax.mail.internet.InternetAddress fromAddress,
javax.mail.internet.InternetAddress[] toAddress,
String subject,
String messageBody)
Sends a text-only mail message with less addressing information to specified addresses. |
void |
sendMail(javax.mail.internet.InternetAddress fromAddress,
javax.mail.internet.InternetAddress[] toAddress,
String subject,
String messageBody,
String encoding)
Sends an encoded text-only mail message with less addressing information to specified addresses. |
void |
sendMail(javax.mail.internet.InternetAddress fromAddress,
javax.mail.internet.InternetAddress toAddress,
String subject,
String messageBody)
Sends a text-only mail message with less addressing information to the specified addresses. |
void |
sendMail(javax.mail.internet.InternetAddress fromAddress,
javax.mail.internet.InternetAddress toAddress,
String subject,
String messageBody,
String encoding)
Sends an encoded text-only mail message with less addressing information to the specified address. |
void |
sendMail(javax.mail.internet.InternetAddress toAddress,
String subject,
String messageBody)
Sends a text-only mail message with minimal addressing information to the specified address. |
void |
setDebug(boolean debug)
Sets debugging flag for JavaMail Session object. |
void |
setExecutorName(ObjectName executor)
Sets the executor of this executable. |
void |
setFrom(javax.mail.internet.InternetAddress from)
Sets the address of the current user. |
void |
setHost(String host)
Sets the host name of the mail server. |
void |
setHost(String host,
String protocol)
Sets the protocol specific host name of the mail server. |
void |
setPassword(String password)
Sets the password for connecting the mail server. |
void |
setPassword(String password,
String protocol)
Sets the protocol specific password for connecting the mail server. |
void |
setPort(int port)
Sets the port number of the mail server. |
void |
setPort(int port,
String protocol)
Sets the protocol specific port number of the mail server. |
void |
setProtocol(String protocol)
Sets the protocol for sending. |
void |
setUser(String user)
Sets the username for connecting the mail server. |
void |
setUser(String user,
String protocol)
Sets the protocol specific username for connecting the mail server. |
void |
start()
Starts the MBean. |
void |
stop()
Stops the mail queue and discards unsent mail messages. |
protected void |
validateConfiguration(Configuration config)
Validates the configuration. |
Methods inherited from class org.norther.tammi.core.base.Adaptee |
---|
addAdaptee, addNotificationListener, getAttributeSupport, getBroker, getCanonicalName, getDomain, getFactory, getLoader, getLog, getLog, getMBean, getMBeanServer, getNotificationInfo, getObjectName, getRegistrationTime, getSequenceNumber, hasListeners, isRegistered, postmanaged, premanaged, removeNotificationListener, removeNotificationListener, sendNotification, sendNotification, sendNotification, sendNotification, unmanaged, unregister |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Methods inherited from interface org.norther.tammi.core.config.Configurable |
---|
addProperty, addProperty, addPropertyFilePath, addPropertyFilePath, clearProperties, containsProperty, getConfigKey, getProperties, getProperty, getPropertyFilePath, getPropertyFilePaths, indexOfProperty, propertyMap, propertyMap, removeProperty, removeProperty, removePropertyFilePath, setConfigKey, setProperties, setProperty, setPropertyFilePath, setPropertyFilePath, setPropertyFilePaths, setPropertyFilePaths, storeProperties |
Constructor Detail |
---|
public DefaultMailer()
Method Detail |
---|
public ObjectName getExecutorName()
Executable
getExecutorName
in interface Executable
public void setExecutorName(ObjectName executor)
Executable
Note that it will be taken into use after next start.
setExecutorName
in interface Executable
executor
- the object name of the executor or a query.public boolean isStarted()
Startable
isStarted
in interface Startable
public void start() throws Exception
Startable
start
in interface Startable
Exception
- if start fails.public void stop()
stop
in interface Startable
public String getServerURL()
Mailer
getServerURL
in interface Mailer
public void applyServerURL(String server)
Mailer
If null is given, initializes both the protocol specific and general settings.
applyServerURL
in interface Mailer
server
- the URL of the mail server to be connected as a string.public String getProtocol()
Mailer
getProtocol
in interface Mailer
public void setProtocol(String protocol)
Mailer
setProtocol
in interface Mailer
protocol
- the protocol e.g. 'SMTP'.public String getHost()
Mailer
getHost
in interface Mailer
public void setHost(String host)
Mailer
setHost
in interface Mailer
host
- the host name.public void setHost(String host, String protocol)
Mailer
setHost
in interface Mailer
host
- the host name.protocol
- the protocol.public int getPort()
Mailer
getPort
in interface Mailer
public void setPort(int port)
Mailer
setPort
in interface Mailer
port
- the port number.public void setPort(int port, String protocol)
Mailer
setPort
in interface Mailer
port
- the port number.protocol
- the protocol.public String getUser()
Mailer
getUser
in interface Mailer
public void setUser(String user)
Mailer
setUser
in interface Mailer
user
- the username.public void setUser(String user, String protocol)
Mailer
setUser
in interface Mailer
user
- the username.protocol
- the protocol.public void setPassword(String password)
Mailer
setPassword
in interface Mailer
password
- the password.public void setPassword(String password, String protocol)
Mailer
setPassword
in interface Mailer
password
- the password.protocol
- the protocol.public javax.mail.internet.InternetAddress getFrom()
Mailer
InternetAddress.getLocalAddress
method to specify the
current user's email, default username@host.
getFrom
in interface Mailer
public void setFrom(javax.mail.internet.InternetAddress from)
Mailer
InternetAddress.getLocalAddress
method to specify the
current user's email, default username@host.
setFrom
in interface Mailer
from
- the user mail address.public boolean getDebug()
Mailer
getDebug
in interface Mailer
public void setDebug(boolean debug)
Mailer
setDebug
in interface Mailer
debug
- the debug flag.public void sendMail(javax.mail.internet.InternetAddress toAddress, String subject, String messageBody) throws LogException
Mailer
sendMail
in interface Mailer
toAddress
- the receiver's mail address.subject
- the subject of the mail.messageBody
- the mail body as text.
LogException
- if the addresses cannot be parsed or other problems
in setting the data.public void sendMail(javax.mail.internet.InternetAddress[] toAddress, String subject, String messageBody) throws LogException
Mailer
sendMail
in interface Mailer
toAddress
- the receivers' mail addresses.subject
- the subject of the mail.messageBody
- the mail body as text.
LogException
- if the addresses cannot be parsed or other problems
in setting the data.public void sendMail(javax.mail.internet.InternetAddress fromAddress, javax.mail.internet.InternetAddress toAddress, String subject, String messageBody) throws LogException
Mailer
sendMail
in interface Mailer
fromAddress
- the sender's mail address.toAddress
- the receiver's mail address.subject
- the subject of the mail.messageBody
- the mail body as text.
LogException
- if the addresses cannot be parsed or other problems
in setting the data.public void sendMail(javax.mail.internet.InternetAddress fromAddress, javax.mail.internet.InternetAddress[] toAddress, String subject, String messageBody) throws LogException
Mailer
sendMail
in interface Mailer
fromAddress
- the sender's mail address.toAddress
- the receivers' mail addresses.subject
- the subject of the mail.messageBody
- the mail body as text.
LogException
- if the addresses cannot be parsed or other problems
in setting the data.public void sendMail(javax.mail.internet.InternetAddress fromAddress, javax.mail.internet.InternetAddress toAddress, String subject, String messageBody, String encoding) throws LogException
Mailer
sendMail
in interface Mailer
fromAddress
- the sender's mail address.toAddress
- the receiver's mail address.subject
- the subject of the mail.messageBody
- the mail body as text.encoding
- the charset to be applied.
LogException
- if the addresses cannot be parsed or other problems
in setting the data.public void sendMail(javax.mail.internet.InternetAddress fromAddress, javax.mail.internet.InternetAddress[] toAddress, String subject, String messageBody, String encoding) throws LogException
Mailer
sendMail
in interface Mailer
fromAddress
- the sender's mail address.toAddress
- the receivers' mail addresses.subject
- the subject of the mail.messageBody
- the mail body as text.encoding
- the charset to be applied.
LogException
- if the addresses cannot be parsed or other problems
in setting the data.public void sendMail(javax.mail.internet.InternetAddress fromAddress, javax.mail.internet.InternetAddress[] replyToAddress, javax.mail.internet.InternetAddress senderAddress, javax.mail.internet.InternetAddress[] toAddress, javax.mail.internet.InternetAddress[] ccAddress, javax.mail.internet.InternetAddress[] bccAddress, String subject, String messageBody) throws LogException
Mailer
sendMail
in interface Mailer
fromAddress
- the sender's mail address.replyToAddress
- reply to addresses (see RFC822 for details).senderAddress
- sender addresses (see RFC822 for details).toAddress
- the receivers' mail addresses.ccAddress
- the addresses to receive carbon copy of this message.bccAddress
- the addresses to receive blind carbon copy of this
message.subject
- the subject of the mail.messageBody
- the mail body as text.
LogException
- if the addresses cannot be parsed or other problems
in setting the data.public void sendMail(javax.mail.internet.InternetAddress fromAddress, javax.mail.internet.InternetAddress[] replyToAddress, javax.mail.internet.InternetAddress senderAddress, javax.mail.internet.InternetAddress[] toAddress, javax.mail.internet.InternetAddress[] ccAddress, javax.mail.internet.InternetAddress[] bccAddress, String subject, String messageBody, String encoding) throws LogException
Mailer
sendMail
in interface Mailer
fromAddress
- the sender's mail address.replyToAddress
- reply to addresses (see RFC822 for details).senderAddress
- sender addresses (see RFC822 for details).toAddress
- the receivers' mail addresses.ccAddress
- the addresses to receive carbon copy of this message.bccAddress
- the addresses to receive blind carbon copy of this
message.subject
- the subject of the mail.messageBody
- the mail body as text.encoding
- the charset to be applied.
LogException
- if the addresses cannot be parsed or other problems
in setting the data.public void run()
run
in interface Runnable
protected void validateConfiguration(Configuration config)
DefaultConfigurable
validateConfiguration
in class DefaultConfigurable
config
- the configuration.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |