org.liquidsite.util.mail
Class SimpleMailMessage

java.lang.Object
  extended byorg.liquidsite.util.mail.MailMessage
      extended byorg.liquidsite.util.mail.SimpleMailMessage

public class SimpleMailMessage
extends MailMessage

An email message. This class is used for creating email messages for the outgoing mail queue. Even though a message is registered with multiple recipients, a single unique message will be sent to each of the recipients.


Constructor Summary
SimpleMailMessage()
          Creates a new empty mail message.
 
Method Summary
 void addRecipients(java.lang.String recipients)
          Adds a list of message recipients.
protected  javax.mail.internet.MimeMessage getNextMessage(javax.mail.Session session)
          Creates the next Java mail MIME message from this mail message.
 java.lang.String getRecipient()
          Returns a string representation of the message recipient.
 java.lang.String getRecipients()
          Returns a string representation of the list of message recipients.
protected  boolean hasMoreMessages()
          Checks if there remains any Java mail MIME messages to generate.
 boolean isValid()
          Checks if this message is valid.
 void setRecipients(java.lang.String recipients)
          Sets the list of message recipients.
 java.lang.String toString()
          Returns a string representation of this mail message.
 
Methods inherited from class org.liquidsite.util.mail.MailMessage
createMessage, getAttribute, getAttributeNames, getReplyTo, getReplyToAddress, getSubject, getText, setAttribute, setReplyTo, setSubject, setText
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

SimpleMailMessage

public SimpleMailMessage()
Creates a new empty mail message.

Method Detail

toString

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

Returns:
a string representation of this mail message

isValid

public boolean isValid()
Checks if this message is valid. A message becomes valid once it has at least one recipient and non-empty subject and text content.

Overrides:
isValid in class MailMessage
Returns:
true if the message is valid, or false otherwise

getRecipient

public java.lang.String getRecipient()
Returns a string representation of the message recipient. This method is used for logging purposes, so the returned string shouldn't be too long.

Specified by:
getRecipient in class MailMessage
Returns:
the message recipient

getRecipients

public java.lang.String getRecipients()
Returns a string representation of the list of message recipients.

Returns:
the message recipients, each separated with a comma (',')

setRecipients

public void setRecipients(java.lang.String recipients)
                   throws MailMessageException
Sets the list of message recipients. The list is a string of comma separated mail addesses with the format specified in RFC 822. This method will clear any previously existing message recipients.

Parameters:
recipients - the message recipient addresses
Throws:
MailMessageException - if the list of message recipient addresses wasn't possible to parse correctly

addRecipients

public void addRecipients(java.lang.String recipients)
                   throws MailMessageException
Adds a list of message recipients. The list is a string of comma separated mail addesses with the format specified in RFC 822.

Parameters:
recipients - the message recipient addresses
Throws:
MailMessageException - if the list of message recipient addresses wasn't possible to parse correctly

hasMoreMessages

protected boolean hasMoreMessages()
Checks if there remains any Java mail MIME messages to generate.

Specified by:
hasMoreMessages in class MailMessage
Returns:
true if there are more messages to generate, or false otherwise

getNextMessage

protected javax.mail.internet.MimeMessage getNextMessage(javax.mail.Session session)
                                                  throws MailMessageException
Creates the next Java mail MIME message from this mail message.

Specified by:
getNextMessage in class MailMessage
Parameters:
session - the Java mail session
Returns:
the Java MIME message created
Throws:
MailMessageException - if the message couldn't be created correctly