|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
public interface MailetContext
Defines a set of methods that can be used to interact with the mailet container. For example, it can be used to send a new message, to deliver a message locally, or to write to a log file.
Mailets and Matchers can retrieve a MailetContext through their respective MailetConfig and MatcherConfig objects, which are provided to them by the mailet container when they are initialized.
Mailet Context Attributes
The Mailet Context can provide additional configuration or other information not defined in this interface to Mailets and Matchers by using attributes. See your server documentation for information on the attributes it provides.
Every attribute consists of a name and a value. Attribute names should follow the same convention as package names. The Mailet API specification reserves names matching org.apache.james.* and org.apache.mailet.*. Attribute values can be arbitrary objects.
The list of attributes which are currently associated with a mailet
context can be retrieved using the getAttributeNames()
method, and given its name, the value of an attribute can be
retrieved using the getAttribute(java.lang.String)
method.
Method Summary | |
---|---|
void |
bounce(Mail mail,
java.lang.String message)
Bounces the message using a standard format with the given message. |
void |
bounce(Mail mail,
java.lang.String message,
MailAddress bouncer)
Bounces the message using a standard format with the given message. |
java.lang.Object |
getAttribute(java.lang.String name)
Returns the value of the named mailet context attribute, or null if the attribute does not exist. |
java.util.Iterator |
getAttributeNames()
Returns an Iterator over the names of all attributes which are set in this mailet context. |
java.util.Collection |
getMailServers(java.lang.String domain)
Returns the hostnames that are specified as mail handlers for the given domain name. |
int |
getMajorVersion()
Returns the major version number of the Mailet API that this mailet container supports. |
int |
getMinorVersion()
Returns the minor version number of the Mailet API that this mailet container supports. |
MailAddress |
getPostmaster()
Returns the Postmaster address for this mailet context. |
java.lang.String |
getServerInfo()
Returns the name and version of the mailet container on which the mailet is running. |
java.util.Iterator |
getSMTPHostAddresses(java.lang.String domain)
Returns the SMTP host addresses specified as mail handlers for the given domain name. |
boolean |
isLocalEmail(MailAddress mailAddress)
Checks if an address is local, i.e. |
boolean |
isLocalServer(java.lang.String hostname)
Checks if a host name is local, i.e. |
boolean |
isLocalUser(java.lang.String userAccount)
Deprecated. use isLocalEmail(MailAddress) instead |
void |
log(java.lang.String message)
Writes the specified message to a mailet log. |
void |
log(java.lang.String message,
java.lang.Throwable t)
Writes the specified message to a mailet log, along with the stack trace of the given Throwable. |
void |
removeAttribute(java.lang.String name)
Removes the attribute with the given name from this Mail instance. |
void |
sendMail(Mail mail)
Sends an outgoing message to the top of this mailet container's root queue. |
void |
sendMail(MailAddress sender,
java.util.Collection recipients,
javax.mail.internet.MimeMessage message)
Sends an outgoing message to the top of this mailet container's root queue. |
void |
sendMail(MailAddress sender,
java.util.Collection recipients,
javax.mail.internet.MimeMessage message,
java.lang.String state)
Sends an outgoing message to the top of this mailet container's queue for the specified processor. |
void |
sendMail(javax.mail.internet.MimeMessage message)
Sends an outgoing message to the top of this mailet container's root queue. |
void |
setAttribute(java.lang.String name,
java.lang.Object value)
Associates an attribute with the given name and value with this mailet context. |
void |
storeMail(MailAddress sender,
MailAddress recipient,
javax.mail.internet.MimeMessage message)
Deprecated. - use sparingly. Service will be replaced with resource acquired via JNDI. |
Method Detail |
---|
int getMajorVersion()
int getMinorVersion()
java.lang.String getServerInfo()
The returned string is of the form <servername>/<versionnumber>
,
optionally followed by additional information in parentheses. For example,
the JAMES mailet container may return the string "JAMES/1.2"
or "JAMES/1.2 (JDK 1.3.0; Windows NT 4.0 x86)"
.
java.util.Iterator getAttributeNames()
The getAttribute(java.lang.String)
method can be called to
retrieve an attribute's value given its name.
java.lang.Object getAttribute(java.lang.String name)
name
- the attribute name
void setAttribute(java.lang.String name, java.lang.Object value)
If an attribute with the given name already exists, it is replaced, and the previous value is returned.
Attribute names should follow the same convention as package names. The Mailet API specification reserves names matching org.apache.james.* and org.apache.mailet.*.
name
- the attribute namevalue
- the attribute valuevoid removeAttribute(java.lang.String name)
name
- the name of the attribute to be removedvoid log(java.lang.String message)
message
- the message to be written to the logvoid log(java.lang.String message, java.lang.Throwable t)
message
- the message to be written to the logt
- the Throwable whose stack trace is to be written to the logMailAddress getPostmaster()
boolean isLocalServer(java.lang.String hostname)
hostname
- the host name to check
boolean isLocalUser(java.lang.String userAccount)
isLocalEmail(MailAddress)
instead
This given user account string should contain the full user address, i.e. user@domain. If the domain part is missing, "localhost" will be used as the domain name.
userAccount
- the full address of the account to be checked
boolean isLocalEmail(MailAddress mailAddress)
mailAddress
- the full address of the account to be checked
java.util.Collection getMailServers(java.lang.String domain)
domain
- the domain name whose mail handling hosts are requested
java.util.Iterator getSMTPHostAddresses(java.lang.String domain)
getMailServers(java.lang.String)
method and then performing address
resolution lookups on all returned host names in order.
The results are returned as instances of HostAddress
containing the host and address information.
domain
- the domain whose mail handling SMTP host addresses are requested
void sendMail(javax.mail.internet.MimeMessage message) throws javax.mail.MessagingException
message
- the message to send
javax.mail.MessagingException
- if an error occurs accessing or sending the messagevoid sendMail(MailAddress sender, java.util.Collection recipients, javax.mail.internet.MimeMessage message) throws javax.mail.MessagingException
sender
- the message senderrecipients
- the message recipients as a Collection of MailAddress objectsmessage
- the message to send
javax.mail.MessagingException
- if an error occurs accessing or sending the messagevoid sendMail(MailAddress sender, java.util.Collection recipients, javax.mail.internet.MimeMessage message, java.lang.String state) throws javax.mail.MessagingException
sender
- the message senderrecipients
- the message recipients as a Collection of MailAddress objectsmessage
- the message to sendstate
- the state of the message, indicating the name of the processor for
which the message will be queued
javax.mail.MessagingException
- if an error occurs accessing or sending the messagevoid sendMail(Mail mail) throws javax.mail.MessagingException
mail
- - the message that is to sent
javax.mail.MessagingException
- if an error occurs accessing or sending the messagevoid bounce(Mail mail, java.lang.String message) throws javax.mail.MessagingException
The message will be sent to the original sender from the postmaster address
as configured in this mailet context, adding the message to top of mail
server queue using sendMail
.
mail
- the message to bounce, with the original sendermessage
- a descriptive message explaining why the message bounced
javax.mail.MessagingException
- if an error occurs accessing or sending the messagevoid bounce(Mail mail, java.lang.String message, MailAddress bouncer) throws javax.mail.MessagingException
The message will be sent to the original sender from the given address,
adding the message to top of mail server queue using sendMail
.
mail
- the message to bounce, with the original sendermessage
- a descriptive message explaining why the message bouncedbouncer
- the address used as the sender of the bounce message
javax.mail.MessagingException
- if an error occurs accessing or sending the messagevoid storeMail(MailAddress sender, MailAddress recipient, javax.mail.internet.MimeMessage message) throws javax.mail.MessagingException
sender
- - the sender of the incoming messagerecipient
- - the user who is receiving this message (as a complete email address)message
- - the MimeMessage to store in a local mailbox
javax.mail.MessagingException
- - if the message fails to parse
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |