20-06-2013, 04:03 PM
E-Mail Client
E-Mail Client[.pdf (Size: 322.7 KB / Downloads: 156)
Project Description
In this project, I wrote an e-mail client application on top of the provided Java files with the user interface and basic structure. This program takes multiple recipients’ addresses (To, Cc, and Bcc) and attempts to talk to the SMTP server of each recipient in order to deliver the e-mail message with a subject, text body, and unique message-id in the header. It uses the system’s canonical host name and user id as the sender’s address if those values are valid. Otherwise, the program uses the “From” address given by the user. Unfortunately, I did not go far enough to implement MIME type support
Design and Implementation
Initial design and the basic architecture of the web server followed the project description with a few modifications and enhancements. The key implementation is on the SMTPConnection class where the SMTP interaction is happening, which will be described later.
Message class
As described in the previous section, the Message class gets also the Cc and Bcc recipient strings through its constructor. The constructor is modified to only store the input parameter values into the member variables; the Headers string is generated later when the Message object gets ‘validated’ by the validate() method.
In addition to the To, Cc, and Bcc String objects, the Message object maintains three TreeSet objects ToList, CcList, and BccList. TreeSets are chosen so the mail client don’t send the same message to the same recipient more than once, and to preserve the order in which the user listed the addresses in the GUI. The ‘recipientsIterator’ is returned by combining the three TreeSets into one and returning its iterator.
When vaildate() method is called, these ‘lists’ get populated (and stored for later use) by the comma-or-semicolon-separated addresses in the To, Cc, and Bcc strings. Then, these addresses are converted to comma-separated strings and appended to the Headers string for the message header (except that the Bcc addresses are excluded in the header message).
Envelope class
The constructor for the Envelope class needed to change also in order to take the current recipient address string instead of getting it from the Message object. Although SMTP protocol allows multiple RCPT TO commands to be sent, the domains of the recipient addresses have to be acceptable by the SMTP server. In our case, we’re not posting the outgoing mails to our local SMTP server, but directly attempting to send out to the ricipients’ STMP servers, thus the need for the current recipient string.
Conclusions
This project is a very interesting project to learn the SMTP protocol, implement a fun user application, and also get exposed to the MIME extension types. However, I spent too much of my not too available time in getting the multiple recipients support, which ended up not working too well due to the authentication problem.
The given structure of the source code was very intuitive and matched well to how an e-mail message is constructed and sent. MailClient is the GUI frontend and the main application program, Message contains the actual header information and body text, Envelope encapsulates the Message object with the proper information to be used in an SMTP session, and SMTPConnection represents a single SMTP session with a remote server.