|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
public interface Mail
Wraps a MimeMessage with additional routing and processing information.
This includes
The Mail interface also defines constants for special processor names, such as "root" and "error".
Mail Attributes
While processing a Mail instance, a Mailet can associate additional information with it by using mail attributes. These attributes can then be queried by the same mailet or other mailets later on.
Some containers may also use attributes to provide envelope information.
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, but since Mail is Serializable, the attribute value must be Serializable as well.
The list of attributes which are currently associated with a Mail
instance 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. It is also
possible to remove one
attribute or
all
attributes of a Mail instance.
Field Summary | |
---|---|
static String |
DEFAULT
|
static String |
ERROR
|
static String |
GHOST
|
static String |
TRANSPORT
|
Method Summary | |
---|---|
Serializable |
getAttribute(String name)
Returns the value of the named Mail instance 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 Mail instance. |
String |
getErrorMessage()
The error message, if any, associated with this message. |
Date |
getLastUpdated()
Returns the time at which this Mail was last updated. |
javax.mail.internet.MimeMessage |
getMessage()
Returns the MimeMessage stored in this message. |
long |
getMessageSize()
Returns the message size (including headers). |
String |
getName()
Returns the name of this message. |
Collection<MailAddress> |
getRecipients()
Returns the message recipients as a Collection of MailAddress objects, as specified by the SMTP "RCPT TO" command, or internally defined. |
String |
getRemoteAddr()
Returns the IP address of the remote server that sent this message. |
String |
getRemoteHost()
Returns the host name of the remote server that sent this message. |
MailAddress |
getSender()
Returns the sender of the message, as specified by the SMTP "MAIL FROM" command, or internally defined. |
String |
getState()
Returns the current state of the message, such as GHOST, ERROR or DEFAULT. |
boolean |
hasAttributes()
Returns whether this Mail instance has any attributes set. |
void |
removeAllAttributes()
Removes all attributes associated with this Mail instance. |
Serializable |
removeAttribute(String name)
Removes the attribute with the given name from this Mail instance. |
Serializable |
setAttribute(String name,
Serializable object)
Associates an attribute with the given name and value with this Mail instance. |
void |
setErrorMessage(String msg)
Sets the error message associated with this message. |
void |
setLastUpdated(Date lastUpdated)
Sets the time at which this Mail was last updated. |
void |
setMessage(javax.mail.internet.MimeMessage message)
Sets the MimeMessage wrapped by this Mail instance. |
void |
setName(String newName)
Set the name of this message. |
void |
setRecipients(Collection<MailAddress> recipients)
Sets the message recipients as a Collection of MailAddress objects. |
void |
setState(String state)
Sets the state of this message. |
Field Detail |
---|
static final String GHOST
static final String DEFAULT
static final String ERROR
static final String TRANSPORT
Method Detail |
---|
String getName()
void setName(String newName)
newName
- the new message namejavax.mail.internet.MimeMessage getMessage() throws javax.mail.MessagingException
javax.mail.MessagingException
- when an error occurs while retrieving the messageCollection<MailAddress> getRecipients()
void setRecipients(Collection<MailAddress> recipients)
recipients
- the message recipients as a Collection of MailAddress ObjectsMailAddress getSender()
String getState()
String getRemoteHost()
String getRemoteAddr()
String getErrorMessage()
void setErrorMessage(String msg)
msg
- the error messagevoid setMessage(javax.mail.internet.MimeMessage message)
message
- the new message that this Mail instance will wrapvoid setState(String state)
state
- the new state of this messageSerializable getAttribute(String name)
name
- the attribute name
Iterator<String> getAttributeNames()
The getAttribute(java.lang.String)
method can be called to
retrieve an attribute's value given its name.
boolean hasAttributes()
Serializable removeAttribute(String name)
name
- the name of the attribute to be removed
void removeAllAttributes()
Serializable setAttribute(String name, Serializable object)
Conventionally, attribute names should follow the namespacing guidelines for Java packages. The Mailet API specification reserves names matching org.apache.james.* and org.apache.mailet.*.
name
- the attribute nameobject
- the attribute value
long getMessageSize() throws javax.mail.MessagingException
This is intended as a guide suitable for processing heuristics, and not a precise indication of the number of outgoing bytes that would be produced were the email to be encoded for transport. In cases where an exact value is not readily available or is difficult to determine (for example, when the fully transfer encoded message is not available) a suitable estimate may be returned.
javax.mail.MessagingException
- when the size cannot be retrievedDate getLastUpdated()
void setLastUpdated(Date lastUpdated)
lastUpdated
- the time at which this Mail was last modified
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |