Answered step by step
Verified Expert Solution
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: Create Cbased client using TCP sockets The client should run on any cell machine The client should be able to accept email details email header and message from the user as an input text file 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: Create account in smtpgo using your UNT or work email address. Common email domains or others cannot be used to create an account 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 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 A telnet interaction is shown below and use the template to test your SMTP server setup and then proceed to the next step Create a Cbased client using TCP sockets 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 for the SMTP email service provided by smtpgo and Email text file is a txt file that has the email headers from to and subject and the message of the email. The hostname and port number are used by client to make a connection to the requested hostname using the connect system call 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 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 The first command is EHLOand the EHLOstring is sent write or send system call to the SMTP server by the client 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 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 VXNlcmhbWU asking for the username encoded as base The base 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 base using this website. The SMTP server responds with a UGFzcdvcmQ asking for the password encoded as base The base 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 base using the same website. If the account details are correct, the SMTP server responds with a Authentication Succeeded otherwise Incorrect authentication data 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 OK 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 Accepted 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 Enter message, ending with on a line by itself 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 OK idsome id The maximum size of the message can only be KB The client program should repeat itself by again asking the user for the input email text file and should follow Steps 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 mail.smtpgocom closing connection 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. 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: Commented client C code A Makefile to compile make the source code and to clean make clean the executable A readme file that describes how to compile, execute, and test the code. Telnet Interaction: telnet mail.smtpgocom Connected to mail.smtpgocom. Escape character is mail.smtpgocom ESMTP Exim SG Wed, Mar :: EHLO mail.smtpgocom Hello SIZE BITMIME DSN PIPELINING PIPECONNECT AUTH CRAMMD PLAIN LOGIN CHUNKING STARTTLS PRDR SMTPUTF HELP AUTH LOGIN VXNlcmhbWU Base username UGFzcdvcmQ Base password Authentication succeeded MAIL FROM: youraddress@domain.com OK RCPT TO: recipientaddress@domain.com Accepted DATA Enter message, ending with on a line by itself FROM: "Your Name" TO: "Recipient Name" SUBJECT: Test This is a test!!! OK idnSXogukAj quit mail.smtpgocom closing connection Connection closed by foreign host. Client Interaction: emclient SMTP Server: mail.smtpgocom Port: Email text file: testemail.txt Response: mail.smtpgocom ESMTP Exim SG Wed, Mar :: Response: mail.smtpgocom Hello SIZE BITMIME DSN PIPELINING PIPECONNECT AUTH CRAMMD PLAIN LOGIN CHUNKING STARTTLS PRDR SMTPUTF HELP Response: VXNlcmhbWU Username: Base username Response: UGFzcdvcmQ Password: Base password Response: Authentication succeeded Senders email address: youraddress@domain.com Response: OK Recipients email address: recipientaddress@domain.com Response: Accepted Response: 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: OK idsome id Email text file: quit Response: mail.smtpgocom closing connection
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: Create Cbased client using TCP sockets The client should run on any cell machine The client should be able to accept email details email header and message from the user as an input text file 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: Create account in smtpgo using your UNT or work email address. Common email domains or others cannot be used to create an account 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 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 A telnet interaction is shown below and use the template to test your SMTP server setup and then proceed to the next step Create a Cbased client using TCP sockets 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 for the SMTP email service provided by smtpgo and Email text file is a txt file that has the email headers from to and subject and the message of the email. The hostname and port number are used by client to make a connection to the requested hostname using the connect system call 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 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 The first command is EHLOand the EHLOstring is sent write or send system call to the SMTP server by the client 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 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 VXNlcmhbWU asking for the username encoded as base The base 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 base using this website. The SMTP server responds with a UGFzcdvcmQ asking for the password encoded as base The base 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 base using the same website. If the account details are correct, the SMTP server responds with a Authentication Succeeded otherwise Incorrect authentication data 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 OK 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 Accepted 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 Enter message, ending with on a line by itself 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 OK idsome id The maximum size of the message can only be KB The client program should repeat itself by again asking the user for the input email text file and should follow Steps 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 mail.smtpgocom closing connection 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. 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: Commented client C code A Makefile to compile make the source code and to clean make clean the executable A readme file that describes how to compile, execute, and test the code. Telnet Interaction: telnet mail.smtpgocom Connected to mail.smtpgocom. Escape character is mail.smtpgocom ESMTP Exim SG Wed, Mar :: EHLO mail.smtpgocom Hello SIZE BITMIME DSN PIPELINING PIPECONNECT AUTH CRAMMD PLAIN LOGIN CHUNKING STARTTLS PRDR SMTPUTF HELP AUTH LOGIN VXNlcmhbWU Base username UGFzcdvcmQ Base password Authentication succeeded MAIL FROM: youraddress@domain.com OK RCPT TO: recipientaddress@domain.com Accepted DATA Enter message, ending with on a line by itself FROM: "Your Name" TO: "Recipient Name" SUBJECT: Test This is a test!!! OK idnSXogukAj quit mail.smtpgocom closing connection Connection closed by foreign host. Client Interaction: emclient SMTP Server: mail.smtpgocom Port: Email text file: testemail.txt Response: mail.smtpgocom ESMTP Exim SG Wed, Mar :: Response: mail.smtpgocom Hello SIZE BITMIME DSN PIPELINING PIPECONNECT AUTH CRAMMD PLAIN LOGIN CHUNKING STARTTLS PRDR SMTPUTF HELP Response: VXNlcmhbWU Username: Base username Response: UGFzcdvcmQ Password: Base password Response: Authentication succeeded Senders email address: youraddress@domain.com Response: OK Recipients email address: recipientaddress@domain.com Response: Accepted Response: 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: OK idsome id Email text file: quit Response: mail.smtpgocom closing connection
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started