SK.gnome.dwarf.mail.smtp.proc
Interface MailAgentContext

All Known Implementing Classes:
SMTPServer

public interface MailAgentContext

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

getHostName

public java.lang.String getHostName()
Returns the full hostname of the server.

This is also the name of the default mail host contained by the server.

Returns:
the hostname of the server

getMailStore

public MailStore getMailStore(java.lang.String user)
                       throws MailException
Returns the mail store for the given user.

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.

Parameters:
user - the user identification
Returns:
the mail store for the given user
Throws:
MailException

getUserStore

public UserStore getUserStore(java.lang.String user)
                       throws MailException
Returns the user store for the given user.

The user argument may contain a domain part after the '@' character if it represents a virtual domain user.

Parameters:
user - the user identification
Returns:
the user store for the given host or null if not available
Throws:
MailException

isLocalHost

public boolean isLocalHost(java.lang.String hostname)
                    throws MailException
Finds out whether the given argument refers to a local mail host.

Parameters:
hostname - the host name
Returns:
true if the given name refers to a local mail host, false otherwise
Throws:
MailException - if an error occured

isLocalUser

public boolean isLocalUser(java.lang.String user)
                    throws MailException
Finds out whether the given argument refers to a local mail user.

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.

Parameters:
user - the user name or mail address, if it is virtual user
Returns:
true if the given argument refers to a local mail user, false otherwise
Throws:
MailException - if an error occured

getMessageInstance

public SMTPMessage getMessageInstance()
                               throws MailException
Creates a new SMTPMessage istance.

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.

Throws:
MailException

sendMessage

public void sendMessage(SMTPMessage message,
                        java.util.Collection recipients)
                 throws java.io.IOException,
                        MailException
Sends the message.

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.

Parameters:
message - the message to send
recipients - the message recipients represented by the Recipient objects
Throws:
java.io.IOException - if an I/O error occured
MailException - if an error occured

sendMessage

public void sendMessage(MimeMessageBuilder message)
                 throws java.io.IOException,
                        MailException
Sends the message.

The message is put to the mail queue directly, bypassing the network and SMTP protocol overhead.

Parameters:
message - the message to send
Throws:
java.io.IOException - if an I/O error occured
MailException - if an error occured

storeMessage

public void storeMessage(java.lang.String user,
                         java.lang.String folder,
                         java.lang.String from,
                         java.io.InputStream in)
                  throws java.io.IOException,
                         MailException
Stores the message to the given mail folder.

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.

Parameters:
user - the local user name
folder - full name of the target mail folder
from - the From address or null
in - the input stream containing the raw message data
Throws:
java.io.IOException - if an I/O error occured
MailException - if an error occured


Copyright (c) 2004-2005, Gnome Ltd. All rights reserved.