mx4j.tools.mail

Interface SMTPMBean

public interface SMTPMBean

Management Interface of a SMTP MBean.

This MBean is meant to send a mail given certain situation. It may be used to listen to a monitor or timer and send a mail.

To use it you need to add to your classpath the mail.jar from the JavaMail API and the activation.jar from the Java Activation Framework.

Besides you need to configure all the required fields, at least the serverHost and To fields and if your server requires login also the serverUsername and serverPassword fields

The subject and content fields are subject to keyword expansions, i.e. some keyworks put between $ signs will be exapnded this can be used to give a more informative message. The current available expansions are

$date$ -> Current date formatted with locale format $time$ -> Current tim formatted with locale format $datetime$ -> Current date and time formatted with locale format $notification$ -> Notification type $observed$ -> ObjectName of the observed object $objectname$ -> This MBean's objectname

Version: $Revision: 1.4 $

Method Summary
StringgetBCC()
Gets a comma separated list of addresses set in the BCC field
StringgetCC()
Gets a comma separated list of addresses set in the CC field
StringgetContent()
Returns the content of the mail
StringgetFromAddress()
Gets the from address attached to mails
StringgetFromName()
Gets the from name presented on the mail
StringgetMimeType()
Gets the MIME type set to the mail
StringgetNotificationName()
Returns the notification which will trigger the mail sending
ObjectNamegetObservedObject()
Gets the MBean's objectname which is being listened
StringgetServerHost()
Gets the server's host as name or IP
intgetServerPort()
Gets the server's port, by default is 25
StringgetServerUsername()
Gets the username to log to the server
StringgetSubject()
Gets the mail subject
intgetTimeout()
Returns the timeout used when sending mails
StringgetTo()
Gets a comma separated list of addresses set in the TO field
booleanisLoginToServer()
Indicates whether login to the SMTP server will be attpemted
voidsendMail()
This will directly execute the send mail.
voidsetBCC(String bccAddresses)
Sets a comma separated list of address which will go in the BCC mail field
voidsetCC(String ccAddresses)
Sets a comma separated list of address which will go in the CC mail field
voidsetContent(String content)
Sets the content of the mail
voidsetFromAddress(String fromAddress)
Sets the form address set to mail
voidsetFromName(String fromName)
Sets the from name presented on the mail
voidsetLoginToServer(boolean login)
Sets whether to login to the SMTP server
voidsetMimeType(String mimeType)
Sets the MIME type, by default it is text/plain
voidsetNotificationName(String notificationName)
Sets the notification name which will trigger the mail sending.
voidsetObservedObject(ObjectName targetMBeanName)
Sets the observed object.
voidsetServerHost(String host)
Sets the server's host, it can be set as name or IP
voidsetServerPassword(String password)
Sets server's passowrd, use with setLoginToServer(true) and setServerUsername
voidsetServerPort(int port)
Sets the server's port.
voidsetServerUsername(String username)
Sets server's username, use with setLoginToServer(true)
voidsetSubject(String subject)
Sets the mail's subject, by default is Empty subject.
voidsetTimeout(int timeout)
Sets the send timeout, by default it is 10 secs
voidsetTo(String toAddresses)
Sets a comma separated list of address which will go in the TO mail field

Method Detail

getBCC

public String getBCC()
Gets a comma separated list of addresses set in the BCC field

getCC

public String getCC()
Gets a comma separated list of addresses set in the CC field

getContent

public String getContent()
Returns the content of the mail

getFromAddress

public String getFromAddress()
Gets the from address attached to mails

getFromName

public String getFromName()
Gets the from name presented on the mail

getMimeType

public String getMimeType()
Gets the MIME type set to the mail

getNotificationName

public String getNotificationName()
Returns the notification which will trigger the mail sending

getObservedObject

public ObjectName getObservedObject()
Gets the MBean's objectname which is being listened

getServerHost

public String getServerHost()
Gets the server's host as name or IP

getServerPort

public int getServerPort()
Gets the server's port, by default is 25

getServerUsername

public String getServerUsername()
Gets the username to log to the server

getSubject

public String getSubject()
Gets the mail subject

getTimeout

public int getTimeout()
Returns the timeout used when sending mails

getTo

public String getTo()
Gets a comma separated list of addresses set in the TO field

isLoginToServer

public boolean isLoginToServer()
Indicates whether login to the SMTP server will be attpemted

sendMail

public void sendMail()
This will directly execute the send mail. It can be used to manually testing the MBean or direct execution

setBCC

public void setBCC(String bccAddresses)
Sets a comma separated list of address which will go in the BCC mail field

setCC

public void setCC(String ccAddresses)
Sets a comma separated list of address which will go in the CC mail field

setContent

public void setContent(String content)
Sets the content of the mail

setFromAddress

public void setFromAddress(String fromAddress)
Sets the form address set to mail

setFromName

public void setFromName(String fromName)
Sets the from name presented on the mail

setLoginToServer

public void setLoginToServer(boolean login)
Sets whether to login to the SMTP server

setMimeType

public void setMimeType(String mimeType)
Sets the MIME type, by default it is text/plain

setNotificationName

public void setNotificationName(String notificationName)
Sets the notification name which will trigger the mail sending. If it is null any notification will trigger a mail

setObservedObject

public void setObservedObject(ObjectName targetMBeanName)
Sets the observed object. It is expected that the observed MBean is a NotificationBroadcster On the contrary the MBean will not be listening to events

setServerHost

public void setServerHost(String host)
Sets the server's host, it can be set as name or IP

setServerPassword

public void setServerPassword(String password)
Sets server's passowrd, use with setLoginToServer(true) and setServerUsername

setServerPort

public void setServerPort(int port)
Sets the server's port.

setServerUsername

public void setServerUsername(String username)
Sets server's username, use with setLoginToServer(true)

setSubject

public void setSubject(String subject)
Sets the mail's subject, by default is Empty subject. The subject field can contain keyword expansion

setTimeout

public void setTimeout(int timeout)
Sets the send timeout, by default it is 10 secs

setTo

public void setTo(String toAddresses)
Sets a comma separated list of address which will go in the TO mail field
Copyright © 2001-2005 The MX4J Contributors. All Rights Reserved.