Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Please write in C with complete code. Please also explain how to run the program. Objective: Create email client program that can send emails using

Please write in C with complete code. Please also explain how to run the program. Objective: Create email client program that can send emails using the SMTP protocol. Requirements: 1. Create C-based client using TCP sockets 2. The client should run on any cell machine 3. The client should be able to accept email details (email header and message) from the user as an input text file 4. The client should be able to send emails with email details (email header and message) from the input text file using the SMTP protocol. Procedure: 1. Create account in smtp2go using your UNT or work email address. Common email domains or others cannot be used to create an account 2. Once the account is created, activate the account. Log in to the account and go to Sending (left panel)-> SMTP Users and click Add SMTP user button (further right)3. Choose a username and password and click Add SMTP User button to create a new user. You should now see the SMTP username on the SMTP users page. Write down the username and password as we will need this to authenticate the account before we can send emails 4. A telnet interaction is shown below and use the template to test your SMTP server setup and then proceed to the next step 5. Create a C-based client using TCP sockets 6. The client should run on any cell machine and the created client should be able to accept a SMTP email service providers hostname, port, and input file using the below format ./emclient SMTP Server: Port: Email text file: where emclient is the client executable, SMTP Server is the SMTP email service providers hostname, Port is the port number that the SMTP server is listening. The port is 2525 for the SMTP email service provided by smtp2go, and Email text file is a txt file that has the email headers (from, to, and subject) and the message of the email. 7. The hostname and port number are used by client to make a connection to the requested hostname using the connect system call 8. The connect system call needs the IP address of the SMTP server. Use the gethostbyname system call to find the IP address of the SMTP server 9. Once the connection is made, read (read or recv system call) the response and print the response to the screen and manually check if the response is good 10. The first command is EHLOand the EHLOstring is sent (write or send system call) to the SMTP server by the client 11. The client sleeps for a second and then reads (read or recv system call) the response and prints the response to the screen and manually check if the response is good. All the next set of response is received after a sleep of one second and printed to the screen 12. To continue with the process of sending emails, you need to authenticate the SMTP account. An AUTH LOGINcommand is sent to the SMTP server by the client. The SMTP server responds with a 334 VXNlcm5hbWU6 asking for the username encoded as base6413. The base64 encoded username is given by the user and the encoded username with an ending is sent to the SMTP server. The username is encoded as base64 using this website. The SMTP server responds with a 334 UGFzc3dvcmQ6 asking for the password encoded as base6414. The base64 encoded password is given by the user and the encoded password with an ending is sent to the SMTP server. The password is encoded as base64 using the same website. If the account details are correct, the SMTP server responds with a 235 Authentication Succeeded otherwise 535 Incorrect authentication data 15. Once the authentication is successful, the client program opens the input email text file and reads the senders email address (FROM:) and prints it to the screen and then uses that to send a MAIL FROM: command to the SMTP server. The SMTP server responds with a 250 OK.16. The client then reads the recipients email address (TO:) from the input email text file and prints it to the screen and then uses that to send a RCPT TO: command to the SMTP server. The SMTP server responds with a 250 Accepted 17. Once the address details are given the body of the message is started by sending DATAcommand to the SMTP server and the SMTP server responds with 354 Enter message, ending with "." on a line by itself 18. The file pointer for the input email text file is reset to the start of the file and the entire content of the file is read and printed to the screen and then sent to the SMTP server as the data of the email and the SMTP server responds with a 250 OK id=some id. The maximum size of the message can only be 1 KB 19. The client program should repeat itself by again asking the user for the input email text file and should follow Steps 1519.20. The client program should exit or end execution when a quit expression is given as an input email text file and the command quitis sent to the SMTP server to close the connection and SMTP server responds with a 221 mail.smtp2go.com closing connection 21. A client interaction with the SMTP server is shown below as an example. The blue section of the client interaction is the contents of the input email text file. 22. A sample input email text file is posted on Canvas for reference. Modify the input email text file to have valid from and to email addresses to test your client code. Deliverables: 1. Commented client C code 2. A Makefile to compile (make) the source code and to clean (make clean) the executable 3. A readme file that describes how to compile, execute, and test the code. Telnet Interaction: telnet mail.smtp2go.com 2525 Connected to mail.smtp2go.com. Escape character is '^]'.220 mail.smtp2go.com ESMTP Exim 4.96-S2G Wed, 29 Mar 202312:02:22+0000 EHLO 250-mail.smtp2go.com Hello [129.120.151.97]250-SIZE 52428800250-8BITMIME 250-DSN 250-PIPELINING 250-PIPE_CONNECT 250-AUTH CRAM-MD5 PLAIN LOGIN 250-CHUNKING 250-STARTTLS 250-PRDR 250-SMTPUTF8250 HELP AUTH LOGIN 334 VXNlcm5hbWU6 Base64 username 334 UGFzc3dvcmQ6 Base64 password 235 Authentication succeeded MAIL FROM: your_address@domain.com 250 OK RCPT TO: recipient_address@domain.com 250 Accepted DATA 354 Enter message, ending with "." on a line by itself FROM: "Your Name" TO: "Recipient Name" SUBJECT: Test This is a test!!! .250 OK id=1nSXo4-g2u6k4-Aj quit 221 mail.smtp2go.com closing connection Connection closed by foreign host. Client Interaction: ./emclient SMTP Server: mail.smtp2go.com Port: 2525 Email text file: test_email.txt Response: 220 mail.smtp2go.com ESMTP Exim 4.96-S2G Wed, 29 Mar 202312:22:22+0000 Response: 250-mail.smtp2go.com Hello [129.120.151.97]250-SIZE 52428800250-8BITMIME 250-DSN 250-PIPELINING 250-PIPE_CONNECT 250-AUTH CRAM-MD5 PLAIN LOGIN 250-CHUNKING 250-STARTTLS 250-PRDR 250-SMTPUTF8250 HELP Response: 334 VXNlcm5hbWU6 Username: Base64 username Response: 334 UGFzc3dvcmQ6 Password: Base64 password Response: 235 Authentication succeeded Senders email address: your_address@domain.com Response: 250 OK Recipients email address: recipient_address@domain.com Response: 250 Accepted Response: 354 Enter message, ending with "." on a line by itself FROM: "Your Name" TO: "Recipient Name" SUBJECT: Subject of the email This is a test!!! . Response: 250 OK id=some id Email text file: quit Response: 221 mail.smtp2go.com closing connection

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Beginning VB 2008 Databases

Authors: Vidya Vrat Agarwal, James Huddleston

1st Edition

1590599470, 978-1590599471

More Books

Students also viewed these Databases questions