SK.gnome.dwarf.mail.smtp
Class SMTPMessage

java.lang.Object
  extended bySK.gnome.dwarf.mail.smtp.SMTPMessage
All Implemented Interfaces:
MailAgentMessage, java.io.Serializable

public abstract class SMTPMessage
extends java.lang.Object
implements java.io.Serializable, MailAgentMessage

This is an abstract SMTP message.

This object represents both the SMTP envelope information and raw message content of a queued message. Furthemore, it provides also a parsed MimePart view of the message content via the getMimePart() method. SMTPMessage objects are stored and maintained by the mail queue. New object instances may be used to create and send a new RFC 822 messages, as well.

Each MailQueue implementation must extend this class to declare an usefull SMTPMessage class.

See Also:
Serialized Form

Constructor Summary
protected SMTPMessage()
          Creates a new SMTPMessage.
 
Method Summary
protected  void addRecipient(Recipient rcpt)
          Adds the given recipient to the message.
 void addRecipient(Recipient recipient, java.util.Collection expanded)
          Adds the given recipient to the message.
protected  void addRecipients(java.util.Collection rcpts)
          Adds the given recipients to the message.
 boolean get8bitMIME()
          Returns the 8BITMIME SMTP parameter.
 java.lang.String getAuth()
          Returns the AUTH SMTP parameter.
 java.net.InetAddress getClientAddress()
          Returns the SMTP client address.
 java.lang.String getClientDomain()
          Returns the domain name of the SMTP client as provided in the HELO/EHLO command.
 long getCurrentDeliveryDelay(Recipient recipient)
          Returns the current delivery delay for the given recipient.
 java.lang.String getDate()
          Returns the internal message time formatted as per RFC 822.
 boolean getDeliverBy()
          Returns the DELIVERBY SMTP parameter.
 char getDeliverByMode()
          Returns the BYTIME SMTP parameter.
 int getDeliverByTime()
          Returns the BYTIME SMTP parameter.
 boolean getDeliverByTrace()
          Returns the BYTRACE SMTP parameter.
protected  int getDeliveryDelay()
          Returns the delivery delay in milliseconds.
 java.lang.String getDSNEnvid()
          Returns the DSNENVID SMTP parameter.
 java.lang.String getDSNRet()
          Returns the DSNRET SMTP parameter.
 java.lang.String getFrom()
          Returns the SMTP reverse-path value.
abstract  java.io.InputStream getInputStream()
          Returns the message content.
abstract  long getMessageSize()
          Returns the message size.
abstract  MimePart getMimePart()
          Returns a parsed MIME interpretation of the message.
 java.lang.String getProtocol()
          Returns the submission protocol.
 java.util.Collection getRecipients()
          Returns the message recipients.
 int getRecipientsSize()
           
 java.net.InetAddress getServerAddress()
          Returns the local SMTP server's address.
 java.lang.String getSMTPid()
          Returns the SMTP identification string.
 long getTime()
          Returns the internal message time.
 boolean isFinished()
          Whether the message is finished.
protected abstract  boolean isStored()
          Whether the message is store in the mail queue.
 void set8bitMIME(boolean enable)
          Sets the 8BITMIME parameter.
protected  void setAuth(java.lang.String auth)
          Sets the AUTH parameter value.
protected  void setClientAddress(java.net.InetAddress address)
          Sets the SMTP client address.
protected  void setClientDomain(java.lang.String domain)
          Sets the SMTP client domain name.
abstract  void setContent(java.io.InputStream in)
          Sets the content of the message.
protected  void setDeliverBy(boolean value)
          Sets the DELIVERBY parameter.
protected  void setDeliverByMode(char mode)
          Sets the BYMODE parameter.
protected  void setDeliverByTime(int time)
          Sets the BYTIME parameter.
protected  void setDeliverByTrace(boolean set)
          Sets the BYTRACE parameter.
 void setDeliveryDelay(int delay)
          Sets the delivery delay of the message in milliseconds.
 void setDSNEnvid(java.lang.String envid)
          Sets the DSNENVID parameter.
 void setDSNRet(java.lang.String ret)
          Sets the DSNRET parameter.
 void setFrom(java.lang.String from)
          Sets the SMTP reverse-path value.
protected  void setProtocol(java.lang.String protocol)
          Sets the protocol identification.
protected  void setServerAddress(java.net.InetAddress address)
          Sets the local SMTP server's address.
protected  void setSMTPid(java.lang.String smtpId)
          Sets the SMTP identification of the message.
protected  void setTime(long time)
          Sets the internal message time.
protected abstract  void store()
          Stores this message to the mail queue.
protected abstract  void storeRecipients(java.util.Collection recipients)
          Updates the given recipients in the mail queue.
 java.lang.String toString()
          Returns a string representation of the message.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

SMTPMessage

protected SMTPMessage()
Creates a new SMTPMessage.

Method Detail

getTime

public long getTime()
Description copied from interface: MailAgentMessage
Returns the internal message time.

Returns the system time in the moment the message was created.

Specified by:
getTime in interface MailAgentMessage
Returns:
the message time

getDate

public java.lang.String getDate()
Description copied from interface: MailAgentMessage
Returns the internal message time formatted as per RFC 822.

Returns the system time in the moment the message was created.

Specified by:
getDate in interface MailAgentMessage
Returns:
the message time

getSMTPid

public final java.lang.String getSMTPid()
Description copied from interface: MailAgentMessage
Returns the SMTP identification string.

Each message instance has a unique identification string.

Specified by:
getSMTPid in interface MailAgentMessage
Returns:
the id string

getProtocol

public java.lang.String getProtocol()
Description copied from interface: MailAgentMessage
Returns the submission protocol.

One of the "LMTP", "SMTP", "ESMTP" or "LOCAL" values may be returned.

Specified by:
getProtocol in interface MailAgentMessage
Returns:
the protocol string

getClientDomain

public java.lang.String getClientDomain()
Description copied from interface: MailAgentMessage
Returns the domain name of the SMTP client as provided in the HELO/EHLO command.

Specified by:
getClientDomain in interface MailAgentMessage
Returns:
the client's domain name

getClientAddress

public java.net.InetAddress getClientAddress()
Description copied from interface: MailAgentMessage
Returns the SMTP client address.

Specified by:
getClientAddress in interface MailAgentMessage
Returns:
the client address

getServerAddress

public java.net.InetAddress getServerAddress()
Description copied from interface: MailAgentMessage
Returns the local SMTP server's address.

Specified by:
getServerAddress in interface MailAgentMessage
Returns:
the server address

setFrom

public void setFrom(java.lang.String from)
Sets the SMTP reverse-path value.

Value of the from argument must be a valid RFC 822 address without the display-name part.

Parameters:
from - the RFC 822 address

getFrom

public java.lang.String getFrom()
Description copied from interface: MailAgentMessage
Returns the SMTP reverse-path value.

Specified by:
getFrom in interface MailAgentMessage
Returns:
the RFC 822 address

set8bitMIME

public void set8bitMIME(boolean enable)
Sets the 8BITMIME parameter.

This parameter enables the pure 8bit transfer of a MIME content. It must be supported by the corresponding ESMTP extension.

Parameters:
enable - true to enable the 8bit MIME transfer, false otherwise

get8bitMIME

public boolean get8bitMIME()
Description copied from interface: MailAgentMessage
Returns the 8BITMIME SMTP parameter.

Specified by:
get8bitMIME in interface MailAgentMessage
Returns:
whether the 8BITMIME parameter is set

getAuth

public java.lang.String getAuth()
Description copied from interface: MailAgentMessage
Returns the AUTH SMTP parameter.

Specified by:
getAuth in interface MailAgentMessage
Returns:
the AUTH parameter value or null if it was not issued by the client

setDSNRet

public void setDSNRet(java.lang.String ret)
Sets the DSNRET parameter.

It must be supported by the corresponding ESMTP extension (DSN).

Parameters:
ret - the parameter value

getDSNRet

public java.lang.String getDSNRet()
Description copied from interface: MailAgentMessage
Returns the DSNRET SMTP parameter.

Specified by:
getDSNRet in interface MailAgentMessage
Returns:
the parameter value

setDSNEnvid

public void setDSNEnvid(java.lang.String envid)
Sets the DSNENVID parameter.

It must be supported by the corresponding ESMTP extension (DSN).

Parameters:
envid - the parameter value

getDSNEnvid

public java.lang.String getDSNEnvid()
Description copied from interface: MailAgentMessage
Returns the DSNENVID SMTP parameter.

Specified by:
getDSNEnvid in interface MailAgentMessage
Returns:
the parameter value

getDeliverBy

public boolean getDeliverBy()
Description copied from interface: MailAgentMessage
Returns the DELIVERBY SMTP parameter.

Specified by:
getDeliverBy in interface MailAgentMessage
Returns:
the parameter value

getDeliverByTime

public int getDeliverByTime()
Description copied from interface: MailAgentMessage
Returns the BYTIME SMTP parameter.

Specified by:
getDeliverByTime in interface MailAgentMessage
Returns:
the parameter value

getDeliverByMode

public char getDeliverByMode()
Description copied from interface: MailAgentMessage
Returns the BYTIME SMTP parameter.

Specified by:
getDeliverByMode in interface MailAgentMessage
Returns:
the parameter value

getDeliverByTrace

public boolean getDeliverByTrace()
Description copied from interface: MailAgentMessage
Returns the BYTRACE SMTP parameter.

Specified by:
getDeliverByTrace in interface MailAgentMessage
Returns:
the parameter value

setDeliveryDelay

public void setDeliveryDelay(int delay)
Sets the delivery delay of the message in milliseconds.

When greater than zero the message delivery will be delayed for the specified amount of time. This is useful when preventing mail looping in some very special cases.

Parameters:
delay - the delay in

getCurrentDeliveryDelay

public long getCurrentDeliveryDelay(Recipient recipient)
Description copied from interface: MailAgentMessage
Returns the current delivery delay for the given recipient.

Specified by:
getCurrentDeliveryDelay in interface MailAgentMessage
Parameters:
recipient - the recipient
Returns:
the delay in milliseconds

getRecipients

public java.util.Collection getRecipients()
Returns the message recipients.

Returns:
unmodifiable collection of all message recipients

getRecipientsSize

public int getRecipientsSize()

addRecipient

public void addRecipient(Recipient recipient,
                         java.util.Collection expanded)
Adds the given recipient to the message.

Parameters:
recipient - the recipient
expanded - list of expanded recipients if the recipient is in fact an alias name

isFinished

public boolean isFinished()
Whether the message is finished.

A message is finished only if all its recipients are finished.

Returns:
true if the message is finished, false otherwise

setContent

public abstract void setContent(java.io.InputStream in)
                         throws java.io.IOException
Sets the content of the message.

Stores the bytes provided by the input stream as the message octets. The input data must be formatted as per RFC 822. The method must not perform any syntax chcecking nor interpret the incoming data in any other way.

Parameters:
in - inpput stream to read the message from
Throws:
java.io.IOException - if the content could not be set

getMessageSize

public abstract long getMessageSize()
Description copied from interface: MailAgentMessage
Returns the message size.

This is the exact size of the whole unparsed message, including the header.

Specified by:
getMessageSize in interface MailAgentMessage
Returns:
the message size

getInputStream

public abstract java.io.InputStream getInputStream()
                                            throws java.io.IOException
Description copied from interface: MailAgentMessage
Returns the message content.

Returns the whole unparsed message octets, including the header.

Specified by:
getInputStream in interface MailAgentMessage
Returns:
the message content
Throws:
java.io.IOException - if an I/O error occured

getMimePart

public abstract MimePart getMimePart()
                              throws MailException
Description copied from interface: MailAgentMessage
Returns a parsed MIME interpretation of the message.

Specified by:
getMimePart in interface MailAgentMessage
Returns:
the MIME view of the message
Throws:
MailException - if an error occured

toString

public java.lang.String toString()
Returns a string representation of the message.

Returns:
the SMTP identification string

isStored

protected abstract boolean isStored()
Whether the message is store in the mail queue.

Returns:
true if the message is store, false otherwise

store

protected abstract void store()
                       throws MailException
Stores this message to the mail queue.

Stores the whole message including the recipient collection.

Throws:
MailException - if an error occured

storeRecipients

protected abstract void storeRecipients(java.util.Collection recipients)
                                 throws MailException
Updates the given recipients in the mail queue.

Updates only information about the given recipients. The recipients collection is always a subset of the original message recipient collection stored in the mail queue.

Parameters:
recipients - the recipients to update
Throws:
MailException - if an error occured

getDeliveryDelay

protected int getDeliveryDelay()
Returns the delivery delay in milliseconds.

Returns:
the delivery delay

setTime

protected void setTime(long time)
Sets the internal message time.

Parameters:
time - the internal time

setSMTPid

protected void setSMTPid(java.lang.String smtpId)
Sets the SMTP identification of the message.

Parameters:
smtpId - the SMTP id

setProtocol

protected void setProtocol(java.lang.String protocol)
Sets the protocol identification.

Parameters:
protocol - the protovol

setClientDomain

protected void setClientDomain(java.lang.String domain)
Sets the SMTP client domain name.

Parameters:
domain - the domain name

setClientAddress

protected void setClientAddress(java.net.InetAddress address)
Sets the SMTP client address.

Parameters:
address - the client address

setServerAddress

protected void setServerAddress(java.net.InetAddress address)
Sets the local SMTP server's address.

Parameters:
address - the server address

setAuth

protected void setAuth(java.lang.String auth)
Sets the AUTH parameter value.

It must be supported by the corresponding ESMTP extension (AUTH).

Parameters:
auth - the parameter value

setDeliverBy

protected void setDeliverBy(boolean value)
Sets the DELIVERBY parameter.

It must be supported by the corresponding ESMTP extension (DELIVERBY).

Parameters:
value - the parameter value

setDeliverByTime

protected void setDeliverByTime(int time)
Sets the BYTIME parameter.

It must be supported by the corresponding ESMTP extension (DELIVERBY).

Parameters:
time - the parameter value

setDeliverByMode

protected void setDeliverByMode(char mode)
Sets the BYMODE parameter.

It must be supported by the corresponding ESMTP extension (DELIVERBY).

Parameters:
mode - the parameter value

setDeliverByTrace

protected void setDeliverByTrace(boolean set)
Sets the BYTRACE parameter.

It must be supported by the corresponding ESMTP extension (DELIVERBY).

Parameters:
set - the parameter value

addRecipient

protected void addRecipient(Recipient rcpt)
Adds the given recipient to the message.

Parameters:
rcpt - the recipient

addRecipients

protected void addRecipients(java.util.Collection rcpts)
Adds the given recipients to the message.

Parameters:
rcpts - the recipients


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