MailClient The MailClient class provides the user with a graphical user interface and calls the other classes as they are needed. This is what it looks like: I took out the From field since I am constructing the sender address instead of using a user supplied value. When you hit the Send Button the MailClient constructs a Message class object to hold the message headers and body. Then the MailClient builds the envelope using the Envelope class. Then the MailClient object creates the SMTPConnection object and opens the connection to the SMTP server. Next the MailClient object sends the message by SMTPConnection.send(). Finally the SMTP closes the connection. The Clear button clears all the fields of the GUI and the QUIT button quits the MailClient altogether. The changes I made to the code in this class were minor. I took out the From information for the GUI and added a Cc field to send Carbon copies. The code is contained at the end of the report as MailClient. Message The Message class object holds the mail message itself, the headers and body. Again I made only a few changes to this class. I needed to set up the Carbon Copy so I added it to the header. I also added two headers Message-Id and Reply-to. The code is contained at the end of the report as Message. Envelope The Envelope class holds the SMTP sender and recipient information, the SMTP server of the recipient’s domain, and the Message Object. Again I made only a few changes to this class as a result of a Carbon copy being sent to a different receiver. The code is contained at the end of the report as Envelope. SMTPConnection The SMTPConnection class opens a connection to the SMTP server over which the message is sent. The standard SMTP Protocol does this. SMTP Protocol SMTP, Simple Mail Transfer Protocol is a standard and reliable host to host mail transport protocol that operates over the TCP port 25. To do this SMTP requires an ordered data stream channel. The model of its design is as follows: the user requests a mail request; the sender established a two-way connection to a receiver. SMTP commands are generated by the sender and sent to the receiver and replies are generated by the receiver and sent to the sender as a response to the command. Once the communication is established the sender sends a MAIL FROM command if the receiver can accept the mail it responds with an OK reply. Sender then sends a RCPT command and if the receiver can accept mail from that recipient responds with an OK reply, otherwise it rejects the recipient. (The receiver can negotiate with more than one recipient.) Then the sender sends the mail data terminating with a special sequence (CRLF.CRLF). If the receiver processes this correctly then it responds with an OK reply. The sender can then send the QUIT command and the connection will be closed. I used the following commands DATA, HELO, MAIL FROM, QUIT and RCPT TO. I also checked for these and other reply codes including those reply codes beginning in 5 that give fatal errors and those beginning in 4, which are not fatal. Here is an example of my protocol for one message without a Cc. -------------------------------------------------------------------------------------------------------220 skinner.villanova.edu ESMTP service (Netscape Messaging Server 4.15 HotFix 0 .3 (built Oct 3 2002)) HELO m234c2 250 skinner.villanova.edu MAIL FROM: <katherine.dawicki@webmail.villanova.edu> 250 Sender <katherine.dawicki@webmail.villanova.edu> Ok RCPT TO: <kmd2102@hotmail.com> 250 Recipient <kmd2102@hotmail.com> Ok DATA 354 Ok Send data ending with <CRLF>.<CRLF> QUIT 221 skinner.villanova.edu ESMTP server closing connection Mail sent succesfully! -------------------------------------------------------------------------------------------------------This is an example with a Carbon copy. -------------------------------------------------------------------------------------------------------220 skinner.villanova.edu ESMTP service (Netscape Messaging Server 4.15 HotFix 0 .3 (built Oct 3 2002)) HELO m234c2 250 skinner.villanova.edu MAIL FROM: <katherine.dawicki@webmail.villanova.edu> 250 Sender <katherine.dawicki@webmail.villanova.edu> Ok RCPT TO: <katherine.dawicki@villanova.edu> 250 Recipient <katherine.dawicki@villanova.edu> Ok DATA 354 Ok Send data ending with <CRLF>.<CRLF> MAIL FROM: <katherine.dawicki@webmail.villanova.edu> 250 Sender <katherine.dawicki@webmail.villanova.edu> Ok RCPT TO: <kmd2102@hotmail.com> 250 Recipient <kmd2102@hotmail.com> Ok DATA 354 Ok Send data ending with <CRLF>.<CRLF> QUIT 221 skinner.villanova.edu ESMTP server closing connection Mail sent succesfully! Test Runs Here is a test run for sending an email without a Carbon Copy. The MailClient GUI raw message The Protocol Mail Received Here is a test run for sending an email with a Carbon Copy. This is a test run with an invalid to address By hitting Clear you Clear the fields Quit button Quits