|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
Provides mail agent context.
This class provides some common useful methods for both mail filters and agents.
Method Summary | |
java.lang.String |
getHostName()
Returns the full hostname of the server. |
MailStore |
getMailStore(java.lang.String user)
Returns the mail store for the given user. |
SMTPMessage |
getMessageInstance()
Creates a new SMTPMessage istance. |
UserStore |
getUserStore(java.lang.String user)
Returns the user store for the given user. |
boolean |
isLocalHost(java.lang.String hostname)
Finds out whether the given argument refers to a local mail host. |
boolean |
isLocalUser(java.lang.String user)
Finds out whether the given argument refers to a local mail user. |
void |
sendMessage(MimeMessageBuilder message)
Sends the message. |
void |
sendMessage(SMTPMessage message,
java.util.Collection recipients)
Sends the message. |
void |
storeMessage(java.lang.String user,
java.lang.String folder,
java.lang.String from,
java.io.InputStream in)
Stores the message to the given mail folder. |
Method Detail |
public java.lang.String getHostName()
This is also the name of the default mail host contained by the server.
public MailStore getMailStore(java.lang.String user) throws MailException
The user argument may contain a domain part after the '@' character if it represents a virtual domain user. There must be a mail store for each user, therefore this method should never return null.
user
- the user identification
MailException
public UserStore getUserStore(java.lang.String user) throws MailException
The user argument may contain a domain part after the '@' character if it represents a virtual domain user.
user
- the user identification
MailException
public boolean isLocalHost(java.lang.String hostname) throws MailException
hostname
- the host name
MailException
- if an error occuredpublic boolean isLocalUser(java.lang.String user) throws MailException
The user argument may contain a domain part after the '@' character if it represents a virtual domain user.
The local part of the user argument is case-sensitive.
user
- the user name or mail address, if it is virtual user
MailException
- if an error occuredpublic SMTPMessage getMessageInstance() throws MailException
The SMTPMessage
object may be used to create and send a new mail message.
It provides more precise control over the delivery process than the MimeMessageBuilder
class.
MailException
public void sendMessage(SMTPMessage message, java.util.Collection recipients) throws java.io.IOException, MailException
The message is put to the mail queue directly, bypassing the network and SMTP protocol overhead.
The recipients collection must contain Recipient objects, representing the actual message recipients.
message
- the message to sendrecipients
- the message recipients represented by the Recipient objects
java.io.IOException
- if an I/O error occured
MailException
- if an error occuredpublic void sendMessage(MimeMessageBuilder message) throws java.io.IOException, MailException
The message is put to the mail queue directly, bypassing the network and SMTP protocol overhead.
message
- the message to send
java.io.IOException
- if an I/O error occured
MailException
- if an error occuredpublic void storeMessage(java.lang.String user, java.lang.String folder, java.lang.String from, java.io.InputStream in) throws java.io.IOException, MailException
The unparsed message content will be read from the given in stream and stored to the local user's folder. The user argument may contain a domain part after the '@' character if it represents a virtual domain user. The from parameter specifies the sender's address (without the display name and comments) and will be used in setting the "Return-Path" header of the stored message, if the message has not been received via the SMTP protocol. If the from argument is null, this header will not be written at all.
This is a direct way how to store a message to the mail store, completely bypassing the queue and agent processing.
user
- the local user namefolder
- full name of the target mail folderfrom
- the From address or nullin
- the input stream containing the raw message data
java.io.IOException
- if an I/O error occured
MailException
- if an error occured
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |