|
||||||||||
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 thegetAttributeNames()
method, and given its name, the value of an attribute can be
retrieved using the getAttribute(java.lang.String)
method.
Nested Class Summary | |
---|---|
static class |
MailetContext.LogLevel
Loglevel for logging operations |
static class |
MailetContext.RecordType
DNS Record Types for lookup operations |
Method Summary | |
---|---|
void |
bounce(Mail mail,
String message)
Bounces the message using a standard format with the given message. |
void |
bounce(Mail mail,
String message,
MailAddress bouncer)
Bounces the message using a standard format with the given message. |
List<String> |
dnsLookup(String name,
MailetContext.RecordType type)
Lookups the DNS system for a given record type. |
Object |
getAttribute(String name)
Returns the value of the named mailet context attribute, or null if the attribute does not exist. |
Iterator<String> |
getAttributeNames()
Returns an Iterator over the names of all attributes which are set in this mailet context. |
Collection<String> |
getMailServers(String domain)
Deprecated. use the generic dnsLookup method |
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. |
String |
getServerInfo()
Returns the name and version of the mailet container on which the mailet is running. |
Iterator<HostAddress> |
getSMTPHostAddresses(String domain)
Deprecated. use the generic dnsLookup method |
boolean |
isLocalEmail(MailAddress mailAddress)
Checks if an address is local, i.e. its account exists locally and this server is the final delivery destination for messages sent to this address. |
boolean |
isLocalServer(String hostname)
Checks if a host name is local, i.e. this server is the final delivery destination for messages sent to this host. |
boolean |
isLocalUser(String userAccount)
Deprecated. use isLocalEmail(MailAddress) instead |
void |
log(MailetContext.LogLevel level,
String message)
Writes the specified message to a mailet log. |
void |
log(MailetContext.LogLevel level,
String message,
Throwable t)
Writes the specified message to a mailet log, along with the stack trace of the given Throwable. |
void |
log(String message)
Deprecated. use log(LogLevel level, String message) |
void |
log(String message,
Throwable t)
Deprecated. use log(LogLevel level, String message, Throwable t) |
void |
removeAttribute(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,
Collection<MailAddress> recipients,
javax.mail.internet.MimeMessage message)
Sends an outgoing message to the top of this mailet container's root queue. |
void |
sendMail(MailAddress sender,
Collection<MailAddress> recipients,
javax.mail.internet.MimeMessage message,
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(String name,
Object value)
Associates an attribute with the given name and value with this mailet context. |
Method Detail |
---|
int getMajorVersion()
int getMinorVersion()
String getServerInfo()
<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)"
.
Iterator<String> getAttributeNames()
getAttribute(java.lang.String)
method can be called to
retrieve an attribute's value given its name.
Object getAttribute(String name)
name
- the attribute name
void setAttribute(String name, Object value)
name
- the attribute namevalue
- the attribute valuevoid removeAttribute(String name)
name
- the name of the attribute to be removed@Deprecated void log(String message)
log(LogLevel level, String message)
message
- the message to be written to the log@Deprecated void log(String message, Throwable t)
log(LogLevel level, String message, Throwable t)
message
- the message to be written to the logt
- the Throwable whose stack trace is to be written to the logvoid log(MailetContext.LogLevel level, String message)
level
- MailetContext.LogLevel
to usemessage
- the message to be written to the logvoid log(MailetContext.LogLevel level, String message, Throwable t)
message
- the message to be written to the logt
- the Throwable whose stack trace is to be written to the loglevel
- MailetContext.LogLevel
to useMailAddress getPostmaster()
boolean isLocalServer(String hostname)
hostname
- the host name to check
@Deprecated boolean isLocalUser(String userAccount)
isLocalEmail(MailAddress)
instead
userAccount
- the full address of the account to be checked
boolean isLocalEmail(MailAddress mailAddress)
mailAddress
- the full address of the account to be checked
Collection<String> getMailServers(String domain)
domain
- the domain name whose mail handling hosts are requested
Iterator<HostAddress> getSMTPHostAddresses(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, Collection<MailAddress> 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, Collection<MailAddress> recipients, javax.mail.internet.MimeMessage message, 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, String message) throws javax.mail.MessagingException
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, String message, MailAddress bouncer) throws javax.mail.MessagingException
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 messageList<String> dnsLookup(String name, MailetContext.RecordType type) throws TemporaryLookupException, LookupException
name
- the host/domain name to lookuptype
- the "IN" record type to lookup
TemporaryLookupException
- on timeout or servfail
LookupException
- on host not found, record type not found, name syntax issues and other permanent exceptions.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |