The Email Client

Your task is to write an email client.  It should be able to connect to an email server, and deliver email to that server.  You must use the SMTP protocol.
 
 

Points

Task

10

Makes a socket to the email server

10

Gets the username and email server name from the user

10

Gets the body of the message from the user

10

Can figure out the MX server programatically (Extra Credit. Very hard. Most people don’t get this!)

60

User actually gets email

-5

Every error check missing from read or write or the response

-10

Not sending headers by Fri Feb 20th

-10

Not done by Wed Feb 25th

Here's a sample dialog between a user and the program
 

Send to whom?> rappleto@nmu.edu
At what SMTP Server?> ALT4.ASPMX.L.GOOGLE.COM
From whom?> rappleto@nmu.edu
Enter the message.  End that message with a '.' on a line by itself. 
Test 2

Message Sent 

Here is the SMTP dialog.

220 mx.google.com ESMTP d75a77b69052e-506a604eb55si92703121cf.353 – gsmtp
HELO nmu.edu
250 mx.google.com at your service
MAIL FROM:<rappleto@nmu.edu>
250 2.1.0 OK d75a77b69052e-506a604eb55si92703121cf.353 – gsmtp
RCPT TO:<rappleto@nmu.edu>
250 2.1.5 OK d75a77b69052e-506a604eb55si92703121cf.353 – gsmtp
DATA
354 Go ahead d75a77b69052e-506a604eb55si92703121cf.353 – gsmtp
Message-ID:<CAEb5kgpPWSWWqL0Kj=Nui2NbTcF+_tB6CKXfAQzdZBpK6wzp=w@mail.gmail.com>
Subject: Vote for me
From:<rappleto@nmu.edu>
To:<rappleto@nmu.edu>

Test 2

.
250 2.0.0 OK 1771210612 d75a77b69052e-506a604eb55si92703121cf.353 – gsmtp
QUIT
221 2.0.0 closing connection d75a77b69052e-506a604eb55si92703121cf.353 - gsmtp



Checklist:

  1. connect to the server port 25

  2. Read from the server. If they don't reply, you're blocked!

  3. send "HELO sourcehostname\r\n"

  4. check for a good reply

  5. send "MAIL FROM: who_you_are\r\n"

  6. check for a good reply

  7. send "RCPT TO: who_gets_this\r\n"

  8. Check for a good reply

  9. Send "DATA\r\n"

  10. Check for a good reply

  11. Send
    Message-ID:<CAEb5kgpPWSWWqL0Kj=Nui2NbTcF+_tB6CKXfAQzdZBpK6wzp=w@mail.gmail.com>
    Subject: Vote for me
    From:<rappleto@nmu.edu>
    To:<rappleto@nmu.edu>

  12. Send "\r\n\r\n"

  13. Send the text of the message and then "\r\n"

  14. Send ".\r\n"

  15. Check for a good reply

  16. Send "QUIT\r\n"

  17. Check for a good reply

  18. exit the program.

  19. Go check you email. It PROBABLY in your spam folder

Notes: NMU Blocks Email