Rakesh API

org.rakeshv.mail
Class WebMailBean

java.lang.Object
  extended by org.rakeshv.mail.WebMailBean
All Implemented Interfaces:
java.util.EventListener, javax.servlet.http.HttpSessionBindingListener

public class WebMailBean
extends java.lang.Object
implements javax.servlet.http.HttpSessionBindingListener

A bean that encapsulates access to the javax.mail package. This bean is used by all the JSP pages and Servlets that constitute the web-mail application to interact with the mail server. This bean throws only the custom MailException when errors are encountered, that cannot be handled safely.

Copyright 2002, Rakesh Vidyadharan

Version:
$Id: WebMailBean.java,v 1.27 2005/08/04 10:44:20 rakesh Exp $
Author:
Rakesh Vidyadharan

Field Summary
private  java.lang.String address
          The internet address that is used in the users email address.
private  AddressBook addressBook
          The AddressBook that belongs to the user.
private  java.lang.String attachmentRootDirectory
          The root directory under which all user-specific mail attachment files are stored.
private static com.stevesoft.pat.Regex[] bodyRegex
          Regex to replace line breaks in message bodies with HTML line breaks.
private static int bodyRegexLength
          int that holds the length of the bodyRegex array.
private  javax.mail.Folder currentFolder
          A reference to the current folder which the user is viewing.
private  javax.mail.Message currentMessage
          The Message instance that represents the currently open message.
private  int currentMessageNumber
          The message number of the message currently open.
private  java.lang.String defaultFrom
          The complete email address of the user that will be used when sending mail.
private  java.lang.String deletedIndicator
          The path to the image that will be used to indicate messages that have been deleted.
private  java.lang.String[] folderNames
          The names of the mail folders available to the user.
private  javax.mail.Folder[] folders
          The mail folders that are available to the user.
private  java.lang.String host
          The hostname of the mail server.
private  java.lang.String inboxFolder
          The name of the default inbox folder in the mail store.
private  MailPreferences mailPreferences
          The MailPreferences for the user.
private  java.lang.String mailTransportProtocol
          The mail transport protocol that is used for sending mail.
private  java.lang.String newIndicator
          The path to the image that will be used to indicate messages that are new.
private  int port
          The port on which the mail server listens for connections.
private  java.lang.String protocol
          The protocol that is used to access mail.
private  java.lang.String readIndicator
          The path to the image that will be used to indicate messages that have been read.
private  java.lang.String repliedIndicator
          The path to the image that will be used to indicate messages that have been replied to.
private static com.stevesoft.pat.Regex replyRegex
          Regex to append a > before each line in the included body of the message used in replies.
private  java.lang.String sentFolderName
          The name of the folder to which sent items are moved.
private  javax.mail.Session session
          The web session for the user using the webmail service.
private static com.stevesoft.pat.Regex singleQuoteRegex
          Regex to replace single quotes (') in addresses with double quotes (").
private  javax.mail.Store store
          The email store to which the user is attempting to connect.
private  java.lang.String trashFolderName
          The name of the folder to which deleted items are moved.
private  java.lang.String user
          The username of the user logging on to the mail server.
private  java.lang.String webserverAttachmentPath
          The webserver path used to access files stored under attachmentRootDirectory.
 
Constructor Summary
WebMailBean()
          Default constructor.
 
Method Summary
private  void cacheFolders()
          Cache all of the folders underneath the default folder.
private  void close()
          Closes the connection to the host/server.
private  void connect(java.lang.String password)
          Attempt to get a connection to the specified host on the specified port as the specified user using the specified password.
private  void copyMessages(javax.servlet.http.HttpServletRequest request)
          Copy the specified message(s) from the currentFolder to the specified folder.
private  void createAttachmentFile(javax.mail.BodyPart bodyPart, java.lang.String directoryName)
          Creates a temporary file under the specified root directory.
private  void createFolder(java.lang.String folder)
          Create the specified folder.
private  void deleteAttachments(java.lang.String directoryName)
          Deletes the temporary attachment files stored under the specified root directory.
private  void deleteFolder(java.lang.String folder)
          Delete the specified folder.
private  void deleteMessages(javax.servlet.http.HttpServletRequest request)
          Delete the specified message(s) from the currentFolder.
private  void destroyOldMessages(javax.mail.Folder folder, int numberOfDays)
          Delete all messages older than numberOfDays days in the specified folder.
 void doCommand(javax.servlet.http.HttpServletRequest request)
          Perform a specialised command.
private  javax.mail.Folder findFolder(java.lang.String folderName)
          Finds a folder based on name out of cached array of folders.
private  javax.mail.Message[] findMessages(java.lang.String[] messageNumbers)
          Turn an array of message numbers as strings into an array of messages from the current folder.
 java.lang.String getAddress()
          Return the value/reference of the address.
 AddressBook getAddressBook()
          Return the value/reference of the addressBook.
 java.lang.String getAttachmentRootDirectory()
          Return the value/reference of the attachmentRootDirectory.
 java.lang.String getDeletedIndicator()
          Return the value/reference of the deletedIndicator.
 java.lang.String getFolderName()
          Get the current folder's name.
 java.lang.String[] getFolderNames()
          Get the names of all the cached folders.
 java.lang.String getFrom()
          The FROM address is useraddress.
 java.lang.String getHost()
          Return the value/reference of the host.
 java.lang.String getInboxFolder()
          Return the value/reference of the inboxFolder.
 MailPreferences getMailPreferences()
          Return the value/reference of the mailPreferences.
 java.lang.String getMailTransportProtocol()
          Return the value/reference of the mailTransportProtocol.
 int getMessageCount()
          Return the number of messages in the current folder.
 java.lang.String getMessageFlag()
          Get the Flags for the message.
 java.lang.String getMessageFrom()
          Get the current message's first from address or reply-to address as a string.
 int getMessageNumber()
          Get the current message's number.
 java.lang.String getMessageReplyTo()
          Get the current message's reply-to address as a string.
 java.lang.String getMessageReplyToAll()
          Get the addresses of all the addressees in the message.
 java.lang.String getMessageSentDate()
          Get the current message's sent date as a string.
 java.lang.String getMessageSize()
          Get the current message's size as an abbreviated string.
 java.lang.String getMessageSubject()
          Get the current message's subject.
 java.lang.String getMessageText()
          Get the text for the message.
 java.lang.String getMessageTo()
          Get the current message's first to address as a string.
 java.lang.String getNewIndicator()
          Return the value/reference of the newIndicator.
 java.lang.String[] getOtherFolderNames()
          Get the names of all the folders except for the current one.
 int getPort()
          Return the value/reference of the port.
 java.lang.String getReadIndicator()
          Return the value/reference of the readIndicator.
 java.lang.String getRepliedIndicator()
          Return the value/reference of the repliedIndicator.
 java.lang.String getReplyText()
          Get the text for the message to use to display in the reply.
 java.lang.String getSentFolder()
          Return the value/reference of the sentFolderName.
 java.lang.String getTrashFolder()
          Return the value/reference of the trashFolderName.
 java.lang.String getUser()
          Return the value/reference of the user.
 java.lang.String getWebserverAttachmentPath()
          Return the value/reference of the webserverAttachmentPath.
 void initialiseSession()
          Initialises the session.
 boolean isConnected()
          This can be used by JSP's to determin whether the user needs to login/re-login.
private  void moveMessages(javax.servlet.http.HttpServletRequest request)
          Move the specified message(s) from the currentFolder to the specified folder.
 void sendMessage(WriteFormParser formParser)
          Send a new message.
 void setAddress(java.lang.String address)
          Set the value of address.
 void setAddressBook(AddressBook addressBook)
          Set the value of addressBook.
 void setAttachmentRootDirectory(java.lang.String attachmentRootDirectory)
          Set the value of attachmentRootDirectory.
 void setDeletedIndicator(java.lang.String deletedIndicator)
          Set the value of deletedIndicator.
 void setFolder(java.lang.String folderName)
          Set the specified folder as the current folder.
 void setHost(java.lang.String host)
          Set the value of host.
 void setInboxFolder(java.lang.String inboxFolder)
          Set the value of inboxFolder.
 void setMailPreferences(MailPreferences mailPreferences)
          Set the value of mailPreferences.
 void setMailTransportProtocol(java.lang.String mailTransportProtocol)
          Set the value of mailTransportProtocol.
 void setMessage(int messageNumber)
          Set the bean's current message to the specified number.
 void setNewIndicator(java.lang.String newIndicator)
          Set the value of newIndicator.
 void setPassword(java.lang.String password)
          Set the password for the user.
 void setPort(int port)
          Set the value of port.
 void setProtocol(java.lang.String protocol)
          Set the value of protocol.
 void setReadIndicator(java.lang.String readIndicator)
          Set the value of readIndicator.
 void setRepliedIndicator(java.lang.String repliedIndicator)
          Set the value of repliedIndicator.
 void setSentFolder(java.lang.String sentFolderName)
          Set the value of sentFolderName.
 void setTrashFolder(java.lang.String trashFolderName)
          Set the value of trashFolderName.
 void setUser(java.lang.String user)
          Set the value of user.
 void setWebserverAttachmentPath(java.lang.String webserverAttachmentPath)
          Set the value of webserverAttachmentPath.
 void valueBound(javax.servlet.http.HttpSessionBindingEvent event)
          HttpSessionBindingListener methods.
 void valueUnbound(javax.servlet.http.HttpSessionBindingEvent event)
          Close the store when the session ends.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

inboxFolder

private java.lang.String inboxFolder
The name of the default inbox folder in the mail store. This field is configured in the web.xml file for the web application.

The following code shows one way of accessing the value defined from a servlet:

 String inboxFolder = getServletContext().getInitParameter( "inboxFolder" );
 


trashFolderName

private java.lang.String trashFolderName
The name of the folder to which deleted items are moved. This field is configured in the web.xml file for the web application.

The following code shows one way of accessing the value defined from a servlet:

 String trashFolder = getServletContext().getInitParameter( "trashFolder" );
 


sentFolderName

private java.lang.String sentFolderName
The name of the folder to which sent items are moved. This field is configured in the web.xml file for the web application.

The following code shows one way of accessing the value defined from a servlet:

 String sentFolder = getServletContext().getInitParameter( "sentFolder" );
 


attachmentRootDirectory

private java.lang.String attachmentRootDirectory
The root directory under which all user-specific mail attachment files are stored. This field is configured in the web.xml file for the web application.

The following code shows one way of accessing the value defined from a servlet:

 String attachmentRootDirectory = getServletContext().getInitParameter( "attachmentRootDirectory" );
 


webserverAttachmentPath

private java.lang.String webserverAttachmentPath
The webserver path used to access files stored under attachmentRootDirectory. This field is configured in the web.xml file for the web application.

The following code shows one way of accessing the value defined from a servlet:

 String webserverAttachmentPath = getServletContext().getInitParameter( "webserverAttachmentPath" );
 


protocol

private java.lang.String protocol
The protocol that is used to access mail. This field is configured in the web.xml file for the web application.

The following code shows one way of accessing the value defined from a servlet:

 String protocol = getServletContext().getInitParameter( "protocol" );
 


mailTransportProtocol

private java.lang.String mailTransportProtocol
The mail transport protocol that is used for sending mail. This field is configured in the web.xml file for the web application.

The following code shows one way of accessing the value defined from a servlet:

 String mailTransportProtocol = getServletContext().getInitParameter( "mailTransportProtocol" );
 


host

private java.lang.String host
The hostname of the mail server. This field is configured in the web.xml file for the web application.

The following code shows one way of accessing the value defined from a servlet:

 String host = getServletContext().getInitParameter( "hostname" );
 


port

private int port
The port on which the mail server listens for connections. This field is configured in the web.xml file for the web application.

The following code shows one way of accessing the value defined from a servlet:

 String portNumber = getServletContext().getInitParameter( "port" );
 int port = Integer.parseInt( portNumber );
 


address

private java.lang.String address
The internet address that is used in the users email address. This variable contains the @ symbol as well. This field is configured in the web.xml file for the web application.

The following code shows one way of accessing the value defined from a servlet:

 String address = getServletContext().getInitParameter( "address" );
 


repliedIndicator

private java.lang.String repliedIndicator
The path to the image that will be used to indicate messages that have been replied to. The value to use for this field is configured in the web.xml file for the web application.

The following code shows one way of accessing the value defined from a servlet:

 String image = getServletContext().getInitParameter( "repliedIndicator" );
 


readIndicator

private java.lang.String readIndicator
The path to the image that will be used to indicate messages that have been read. The value to use for this field is configured in the web.xml file for the web application.

The following code shows one way of accessing the value defined from a servlet:

 String image = getServletContext().getInitParameter( "readIndicator" );
 


newIndicator

private java.lang.String newIndicator
The path to the image that will be used to indicate messages that are new. The value to use for this field is configured in the web.xml file for the web application.

The following code shows one way of accessing the value defined from a servlet:

 String image = getServletContext().getInitParameter( "newIndicator" );
 


deletedIndicator

private java.lang.String deletedIndicator
The path to the image that will be used to indicate messages that have been deleted. The value to use for this field is configured in the web.xml file for the web application.

The following code shows one way of accessing the value defined from a servlet:

 String image = getServletContext().getInitParameter( "deletedIndicator" );
 


session

private javax.mail.Session session
The web session for the user using the webmail service.


user

private java.lang.String user
The username of the user logging on to the mail server.


defaultFrom

private java.lang.String defaultFrom
The complete email address of the user that will be used when sending mail. This is obtained by combining user with address.


store

private javax.mail.Store store
The email store to which the user is attempting to connect.


folders

private javax.mail.Folder[] folders
The mail folders that are available to the user.


folderNames

private java.lang.String[] folderNames
The names of the mail folders available to the user.


currentFolder

private javax.mail.Folder currentFolder
A reference to the current folder which the user is viewing.


currentMessageNumber

private int currentMessageNumber
The message number of the message currently open.


currentMessage

private javax.mail.Message currentMessage
The Message instance that represents the currently open message.


mailPreferences

private MailPreferences mailPreferences
The MailPreferences for the user. The mail preference settings should ideally be cached in the ServletContext for efficiency, and then set using the mutator method setMailPreferences( MailPreferences ). This bean does not contain any logic to create or get a reference to the user's mail preferences. The reference to the appropriate MailPreferences instance must be set using the mutator method.
   String user = request.getParameter( "user" );
   ServletContext servletContext = getServletContext();
   MailPreferences mailPreferences = (MailPreferences) servletContext.getAttribute( "preferences/" + user + ".xml" );
   if ( mailPreferences == null )
   {
     mailPreferences = MailPreferences.createMailPreferences( servletContext.getInitParameter( "addressBookDirectory" ) + "/" + user + ".xml" );
     servletContext.setAttribute( "addressbooks/" + user + ".xml", mailPreferences );
   }
 


addressBook

private AddressBook addressBook
The AddressBook that belongs to the user. The address book should ideally be cached in the ServletContext for efficiency and then set using the mutator method setAddressBook( AddressBook ). This bean does not contain any logic to create or get a reference to the user's address book. The reference to the appropriate address book must be set using the mutator method setAddressBook( AddressBook ).
   String user = request.getParameter( "user" );
   ServletContext servletContext = getServletContext();
   AddressBook addressBook = (AddressBook) servletContext.getAttribute( "addressbooks/" + user + ".xml" );
   if ( addressBook == null )
   {
     addressBook = AddressBook.createAddressBook( servletContext.getInitParameter( "addressBookDirectory" ) + "/" + user + ".xml" );
     servletContext.setAttribute( "addressbooks/" + user + ".xml", addressBook );
   }
 


bodyRegex

private static final com.stevesoft.pat.Regex[] bodyRegex
Regex to replace line breaks in message bodies with HTML line breaks.


replyRegex

private static final com.stevesoft.pat.Regex replyRegex
Regex to append a > before each line in the included body of the message used in replies.


singleQuoteRegex

private static final com.stevesoft.pat.Regex singleQuoteRegex
Regex to replace single quotes (') in addresses with double quotes (").


bodyRegexLength

private static int bodyRegexLength
int that holds the length of the bodyRegex array.

Constructor Detail

WebMailBean

public WebMailBean()
Default constructor. Initialises the session.

See Also:
initialiseSession()
Method Detail

initialiseSession

public final void initialiseSession()
Initialises the session. This method should be called only after setting the mailTransportProtocol, and the host member variables. If the member variables mentioned above are null, then they default to smtp and mail.rakeshv.org respectively.


connect

private void connect(java.lang.String password)
              throws MailException
Attempt to get a connection to the specified host on the specified port as the specified user using the specified password. If successful, the default inboxFolder folder will be opened.

This method also creates the trashFolderName to hold all deleted messages, and the sentFolderName to hold all outgoing messages if they do not already exist.

Parameters:
password - - The password for the user.
Throws:
MailException - - If exceptions are encountered while working with the javax.mail package.

close

private void close()
Closes the connection to the host/server. Prior to closing the connection, all open folders are closed. In addition the following clean-up actions are performed:
  1. All messages older than MailPreferences.daysToKeepDeletedMessages days in the trashFolderName are deleted.
  2. All temporary attachment files created under attachmentRootDirectory are deleted.


destroyOldMessages

private void destroyOldMessages(javax.mail.Folder folder,
                                int numberOfDays)
                         throws javax.mail.MessagingException
Delete all messages older than numberOfDays days in the specified folder. The messages are permanently expunged from the store. Messages older than the limiting date are found by checking the receivedDate and sentDate attributes of the message.

Parameters:
folder - - The folder from which messages are to be removed.
numberOfDays - - The limiting number of days used to determine whether the messages are too old or not.
Throws:
javax.mail.MessagingException - - If errors are encountered while deleting the messages in the specified folder.

cacheFolders

private void cacheFolders()
                   throws MailException
Cache all of the folders underneath the default folder. This will keep us from constantly opening and closing the same folders.

Throws:
MailException - - If MessagingExceptions are encountered while interacting the the mail server.

findFolder

private javax.mail.Folder findFolder(java.lang.String folderName)
Finds a folder based on name out of cached array of folders.

Parameters:
folderName - - The name of the folder to search for.

setFolder

public final void setFolder(java.lang.String folderName)
                     throws MailException
Set the specified folder as the current folder. Only folders underneath the store's default folder can be set. If a folder is already open, close that folder first.

Parameters:
folderName - - The name of the folder to set as the current folder.
Throws:
MailException - - If messaging exceptions are encountered.

getFolderNames

public final java.lang.String[] getFolderNames()
Get the names of all the cached folders.

Returns:
String[] - An array of String objects containing the names of all folders.

getOtherFolderNames

public final java.lang.String[] getOtherFolderNames()
Get the names of all the folders except for the current one. This is useful for operations that move messages from one folder to any of the other available folders.

Returns:
String[] - An array of String objects containing the names of all other folders.

getMessageCount

public final int getMessageCount()
Return the number of messages in the current folder. If a MessagingException is encountered, this method returns -1.

Returns:
int - The number of messages.

setMessage

public final void setMessage(int messageNumber)
Set the bean's current message to the specified number. Pass in 0 to reset the current message pointer.

Parameters:
messageNumber - - The number of the current message.

getMessageNumber

public final int getMessageNumber()
Get the current message's number.

Returns:
int - The number of the current message.

getMessageSentDate

public final java.lang.String getMessageSentDate()
Get the current message's sent date as a string.

Returns:
String - The date of the current message.

getMessageFrom

public final java.lang.String getMessageFrom()
Get the current message's first from address or reply-to address as a string. An empty string will be returned if a MessagingException is encountered.

Returns:
String - The address of the message sender.

getMessageReplyTo

public final java.lang.String getMessageReplyTo()
Get the current message's reply-to address as a string. Return's a comma (, separated string, if multiple addresses are found for the sender.

Returns:
String - The address(s) for the sender.

getMessageReplyToAll

public final java.lang.String getMessageReplyToAll()
Get the addresses of all the addressees in the message. The addresses are returned as a comma (,) separated list of strings. An empty string will be returned if a MessagingException is encountered.

Returns:
String - A comma separated list of addresses.

getMessageTo

public final java.lang.String getMessageTo()
Get the current message's first to address as a string. This method just returns an empty string, if a MessagingException is encountered while fetching the recepients.

Returns:
String - The name of the first recepient.

getMessageSubject

public final java.lang.String getMessageSubject()
Get the current message's subject. This method just returns an empty string, if a MessagingException is encountered while fetching the subject.

Returns:
String - The subject of the message.

getMessageSize

public final java.lang.String getMessageSize()
Get the current message's size as an abbreviated string. This method returns -1 if a MessagingException is encountered while fetching the message size.

Returns:
String - The size of the current message

getMessageFlag

public final java.lang.String getMessageFlag()
Get the Flags for the message. Returns the value corresponding to each Flags.Flag

Note:If a MessagingException is encountered while fetching the flag, this method returns readIndicator.

Note:If an unknown flag is encountered, this method returns newIndicator.

Returns:
String - The indicator corresponding the Flag.

getMessageText

public final java.lang.String getMessageText()
                                      throws MailException

Get the text for the message. If the message is encoded using the multipart MIME type, then, parts of the message that are of type text/* will be displayed inline, and other types of attachments will be presented as links pointing to the temporary attachments files that will created under attachmentRootDirectory.

Use the bodyRegex regular expression(s) to format the body in human readable format.

Returns:
String - The body of the message.
Throws:
MailException - - If errors that cannot be handled by this bean are encountered.

getReplyText

public final java.lang.String getReplyText()

Get the text for the message to use to display in the reply. This method returns an empty string if exceptions are encountered while fetching the body of the message.

Use the replyRegex regular expression(s) to format the body in human readable format.

This only works at present if the message's primary type is "text" or if it is "multipart" and the first body part's primary type is "text".

Returns:
String - The body of the message.

findMessages

private javax.mail.Message[] findMessages(java.lang.String[] messageNumbers)
                                   throws javax.mail.MessagingException
Turn an array of message numbers as strings into an array of messages from the current folder. This can be used for commands that act on multiple messages like delete, copy, and move.

Parameters:
messageNumbers - - The array of message numbers which are to be operated on.
Returns:
Message[] - An array of messages.
Throws:
javax.mail.MessagingException - - If exceptions are encountered while getting the messages specified by the messageNumbers.

createAttachmentFile

private void createAttachmentFile(javax.mail.BodyPart bodyPart,
                                  java.lang.String directoryName)
                           throws javax.mail.MessagingException,
                                  java.io.IOException
Creates a temporary file under the specified root directory. The attachment will be stored under <rootDirectory>/<user>/<fileName>

Parameters:
bodyPart - - The Part of the message that contains the attachment.
directoryName - - The root directory under which the attachment will be stored.
Throws:
java.io.IOException - - Any errors while attempting to write to the OutputStream are propagated back to the caller. An IOException may also be thrown by the IMAP server while fetching the contents of the message.
javax.mail.MessagingException - - Any errors encountered while interacting with the IMAP server are passed back to the caller.

deleteAttachments

private void deleteAttachments(java.lang.String directoryName)
Deletes the temporary attachment files stored under the specified root directory. The attachment are stored under <rootDirectory>/<user>/ directory.

Parameters:
directoryName - - The root directory under which the attachment will be stored.

doCommand

public final void doCommand(javax.servlet.http.HttpServletRequest request)
                     throws MailException

Perform a specialised command. The request's parameters should contain a value named "command" and an array of message numbers called "number".

The copy and move commands need a folder name in the "to" parameter.

The send command needs from, to, cc, bcc, subject, and text parameters. It can also have a reply parameter that indicates the message should be a reply to an existing message in the current folder.

This isn't very elegant, but it is better than putting the code in a JSP.

Throws:
MailException

copyMessages

private void copyMessages(javax.servlet.http.HttpServletRequest request)
                   throws MailException
Copy the specified message(s) from the currentFolder to the specified folder.

Parameters:
request - - The request which contains the information about the message(s) to be copied.
Throws:
MailException - - If errors are encountered while copying the messages.

moveMessages

private void moveMessages(javax.servlet.http.HttpServletRequest request)
                   throws MailException
Move the specified message(s) from the currentFolder to the specified folder.

Parameters:
request - - The request which contains the information about the message(s) to be copied.
Throws:
MailException - - If errors are encountered while copying the messages.

deleteMessages

private void deleteMessages(javax.servlet.http.HttpServletRequest request)
                     throws javax.mail.MessagingException,
                            MailException
Delete the specified message(s) from the currentFolder. Depending upon the user preferences, the message will be deleted permanently or moved to the trashFolderName.

Note: This method throws back the original MessagingException encountered to the calling method. The reason is to allow the caller the opportunity retry the operation if so desired.

Parameters:
request - - The request which contains the information about the message(s) to be copied.
Throws:
javax.mail.MessagingException - - If errors are encountered while deleting the messages.
MailException

createFolder

private void createFolder(java.lang.String folder)
                   throws MailException
Create the specified folder.

Parameters:
folder - - The name of the new folder to create.
Throws:
MailException - - If errors are encountered while creating the folder.

deleteFolder

private void deleteFolder(java.lang.String folder)
                   throws MailException
Delete the specified folder.

Parameters:
folder - - The name of the folder to delete.
Throws:
MailException - - If errors are encountered while deleting the folder.

sendMessage

public void sendMessage(WriteFormParser formParser)
                 throws MailException
Send a new message. The message may be a reply to an existing message, or a totally new message. Uses the SendHandler class to create the new Message being created.

Parameters:
formParser - - The parser which has parsed out the elements from the write.jsp html multipart form.
Throws:
MailException - - If errors are encountered while parsing the multipart form post, or sending the message.
See Also:
SendHandler, WriteFormParser

valueBound

public void valueBound(javax.servlet.http.HttpSessionBindingEvent event)
HttpSessionBindingListener methods.

Specified by:
valueBound in interface javax.servlet.http.HttpSessionBindingListener

valueUnbound

public void valueUnbound(javax.servlet.http.HttpSessionBindingEvent event)
Close the store when the session ends.

Specified by:
valueUnbound in interface javax.servlet.http.HttpSessionBindingListener

getInboxFolder

public final java.lang.String getInboxFolder()
Return the value/reference of the inboxFolder.

Returns:
String - The value/reference of inboxFolder.

setInboxFolder

public final void setInboxFolder(java.lang.String inboxFolder)
Set the value of inboxFolder.

Parameters:
inboxFolder - - The value to set.

getTrashFolder

public final java.lang.String getTrashFolder()
Return the value/reference of the trashFolderName.

Returns:
String - The value/reference of trashFolderName.

setTrashFolder

public final void setTrashFolder(java.lang.String trashFolderName)
Set the value of trashFolderName.

Parameters:
trashFolderName - - The value to set.

getSentFolder

public final java.lang.String getSentFolder()
Return the value/reference of the sentFolderName.

Returns:
String - The value/reference of sentFolderName.

setSentFolder

public final void setSentFolder(java.lang.String sentFolderName)
Set the value of sentFolderName.

Parameters:
sentFolderName - - The value to set.

getAttachmentRootDirectory

public final java.lang.String getAttachmentRootDirectory()
Return the value/reference of the attachmentRootDirectory.

Returns:
String - The value/reference of attachmentRootDirectory.

setAttachmentRootDirectory

public final void setAttachmentRootDirectory(java.lang.String attachmentRootDirectory)
Set the value of attachmentRootDirectory.

Parameters:
attachmentRootDirectory - - The value to set.

getWebserverAttachmentPath

public final java.lang.String getWebserverAttachmentPath()
Return the value/reference of the webserverAttachmentPath.

Returns:
String - The value/reference of webserverAttachmentPath.

setWebserverAttachmentPath

public final void setWebserverAttachmentPath(java.lang.String webserverAttachmentPath)
Set the value of webserverAttachmentPath.

Parameters:
webserverAttachmentPath - - The value to set.

getAddress

public final java.lang.String getAddress()
Return the value/reference of the address.

Returns:
String - The value/reference of address.

setAddress

public final void setAddress(java.lang.String address)
Set the value of address.

Parameters:
address - - The value to set.

getAddressBook

public final AddressBook getAddressBook()
Return the value/reference of the addressBook.

Returns:
AddressBook - The value/reference of addressBook.

setAddressBook

public final void setAddressBook(AddressBook addressBook)
Set the value of addressBook.

Parameters:
addressBook - - The value to set.

setProtocol

public final void setProtocol(java.lang.String protocol)
Set the value of protocol.

Parameters:
protocol - - The protocol to use

getHost

public final java.lang.String getHost()
Return the value/reference of the host.

Returns:
String - The value/reference of host.

setHost

public final void setHost(java.lang.String host)
Set the value of host.

Parameters:
host - - The value to set.

getPort

public final int getPort()
Return the value/reference of the port.

Returns:
int - The value/reference of port.

setPort

public final void setPort(int port)
Set the value of port.

Parameters:
port - - The value to set.

getUser

public final java.lang.String getUser()
Return the value/reference of the user.

Returns:
String - The value/reference of user.

setUser

public final void setUser(java.lang.String user)
Set the value of user.

Parameters:
user - - The value to set.

setPassword

public final void setPassword(java.lang.String password)
                       throws MailException
Set the password for the user. Since the password is sensitive, this bean does not store the password. This is the only way that a calling JSP/Servlet can initiate a connection to the store.

Parameters:
password - - The password for the user.
Throws:
MailException - - If MessagingExceptions are encountered while connecting to the mail server.
See Also:
connect( String )

getFrom

public final java.lang.String getFrom()
The FROM address is useraddress. This value will be created if defaultFrom has not been initialised for some reason.

Returns:
String - The email address of the sender.

isConnected

public final boolean isConnected()
This can be used by JSP's to determin whether the user needs to login/re-login.

Returns:
boolean - Indicates whether the user is still connected to the host/server or not.

getFolderName

public final java.lang.String getFolderName()
Get the current folder's name.

Returns:
String - The name of the current folder.

getMailTransportProtocol

public final java.lang.String getMailTransportProtocol()
Return the value/reference of the mailTransportProtocol.

Returns:
String - The value/reference of mailTransportProtocol.

setMailTransportProtocol

public final void setMailTransportProtocol(java.lang.String mailTransportProtocol)
Set the value of mailTransportProtocol.

Parameters:
mailTransportProtocol - - The value to set.

getRepliedIndicator

public final java.lang.String getRepliedIndicator()
Return the value/reference of the repliedIndicator.

Returns:
String - The value/reference of repliedIndicator.

setRepliedIndicator

public final void setRepliedIndicator(java.lang.String repliedIndicator)
Set the value of repliedIndicator.

Parameters:
repliedIndicator - - The value to set.

getReadIndicator

public final java.lang.String getReadIndicator()
Return the value/reference of the readIndicator.

Returns:
String - The value/reference of readIndicator.

setReadIndicator

public final void setReadIndicator(java.lang.String readIndicator)
Set the value of readIndicator.

Parameters:
readIndicator - - The value to set.

getNewIndicator

public final java.lang.String getNewIndicator()
Return the value/reference of the newIndicator.

Returns:
String - The value/reference of newIndicator.

setNewIndicator

public final void setNewIndicator(java.lang.String newIndicator)
Set the value of newIndicator.

Parameters:
newIndicator - - The value to set.

getDeletedIndicator

public final java.lang.String getDeletedIndicator()
Return the value/reference of the deletedIndicator.

Returns:
String - The value/reference of deletedIndicator.

setDeletedIndicator

public final void setDeletedIndicator(java.lang.String deletedIndicator)
Set the value of deletedIndicator.

Parameters:
deletedIndicator - - The value to set.

getMailPreferences

public final MailPreferences getMailPreferences()
Return the value/reference of the mailPreferences.

Returns:
MailPreferences - The value/reference of mailPreferences.

setMailPreferences

public final void setMailPreferences(MailPreferences mailPreferences)
Set the value of mailPreferences.

Parameters:
mailPreferences - - The value to set.

Rakesh API

Copyright © 2002-2005 - Rakesh Vidyadharan