By the end of this lab, you will have acquired a better understanding of SMTP protocol. You will also gain experience in implementing a standard protocol using Python. Your task is to develop a simple mail client that sends email to any recipient. Your client will need to connect to a mail server, dialogue with the mail server using the SMTP protocol, and send an email message to the mail server. Python provides a module, called smtplib, which has built-in methods to send mail using SMTP protocol. However, you will not be using this module in this lab, because it hides the details of SMTP and socket programming.    In order to limit spam, some mail servers do not accept TCP connections from arbitrary sources. For the experiment described below, you may want to try connecting both to your university mail server and to a popular Webmail server, such as an AOL mail server. To connect to the university mail server, you will need to use NYU’s VPN. You may also try making your connection both from your home and from your university campus.   Code Below you will find the skeleton code for the client. You are to complete the skeleton code. The places where you need to fill in code are marked with #Fill in start and #Fill in end. Each place may require one or more lines of code.    Additional Notes In some cases, the receiving mail server might classify your email as junk. Make sure that you check your junk/spam folder when you look for the email sent from your client.   What to Hand In Use your GitHub repository to upload the complete code for the SMTP mail client. Make sure you follow the SMTP protocol for non-encrypted communication. In this assignment, GradeScope will use a local SMTP server to grade the assignment. Please make sure to use port 1025 and mail server address 127.0.0.1 to receive full credit. Note: Comment out all the print statements in your code, otherwise gradescope will fail to autograde your assignment. Skeleton Code Code is available below and on Google Drive:  https://drive.google.com/file/d/1LhaOggPW2t8dCy6a_sD0i-rGM_sEPU7Y/view?usp=sharing Skeleton Python Code for the Mail Client   from socket import * def smtp_client(port=1025, mailserver='127.0.0.1'):    msg = "\r\n My message"    endmsg = "\r\n.\r\n"      # Choose a mail server (e.g. Google mail server) if you want to verify the script beyond GradeScope      # Create socket called clientSocket and establish a TCP connection with mailserver and port      # Fill in start    # Fill in end      recv = clientSocket.recv(1024).decode()    print(recv)    if recv[:3] != '220':        print('220 reply not received from server.')      # Send HELO command and print server response.    heloCommand = 'HELO Alice\r\n'    clientSocket.send(heloCommand.encode())    recv1 = clientSocket.recv(1024).decode()    print(recv1)    if recv1[:3] != '250':        print('250 reply not received from server.')      # Send MAIL FROM command and print server response.    # Fill in start    # Fill in end      # Send RCPT TO command and print server response.    # Fill in start    # Fill in end      # Send DATA command and print server response.    # Fill in start    # Fill in end      # Send message data.    # Fill in start    # Fill in end      # Message ends with a single period.    # Fill in start    # Fill in end      # Send QUIT command and get server response.    # Fill in start    # Fill in end

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

 

By the end of this lab, you will have acquired a better understanding of SMTP protocol. You will also gain experience in implementing a standard protocol using Python.

Your task is to develop a simple mail client that sends email to any recipient. Your client will need to connect to a mail server, dialogue with the mail server using the SMTP protocol, and send an email message to the mail server. Python provides a module, called smtplib, which has built-in methods to send mail using SMTP protocol. However, you will not be using this module in this lab, because it hides the details of SMTP and socket programming

 

In order to limit spam, some mail servers do not accept TCP connections from arbitrary sources. For the experiment described below, you may want to try connecting both to your university mail server and to a popular Webmail server, such as an AOL mail server. To connect to the university mail server, you will need to use NYU’s VPN. You may also try making your connection both from your home and from your university campus.

 

Code

Below you will find the skeleton code for the client. You are to complete the skeleton code. The places where you need to fill in code are marked with #Fill in start and #Fill in end. Each place may require one or more lines of code. 

 

Additional Notes

In some cases, the receiving mail server might classify your email as junk. Make sure that you check your junk/spam folder when you look for the email sent from your client.

 

What to Hand In

Use your GitHub repository to upload the complete code for the SMTP mail client. Make sure you follow the SMTP protocol for non-encrypted communication. In this assignment, GradeScope will use a local SMTP server to grade the assignment. Please make sure to use port 1025 and mail server address 127.0.0.1 to receive full credit.
Note: Comment out all the print statements in your code, otherwise gradescope will fail to autograde your assignment.



Skeleton Code

Code is available below and on Google Drive: 

https://drive.google.com/file/d/1LhaOggPW2t8dCy6a_sD0i-rGM_sEPU7Y/view?usp=sharing



Skeleton Python Code for the Mail Client

 

from socket import *



def smtp_client(port=1025, mailserver='127.0.0.1'):

   msg = "\r\n My message"

   endmsg = "\r\n.\r\n"

 

   # Choose a mail server (e.g. Google mail server) if you want to verify the script beyond GradeScope

 

   # Create socket called clientSocket and establish a TCP connection with mailserver and port

 

   # Fill in start

   # Fill in end

 

   recv = clientSocket.recv(1024).decode()

   print(recv)

   if recv[:3] != '220':

       print('220 reply not received from server.')

 

   # Send HELO command and print server response.

   heloCommand = 'HELO Alice\r\n'

   clientSocket.send(heloCommand.encode())

   recv1 = clientSocket.recv(1024).decode()

   print(recv1)

   if recv1[:3] != '250':

       print('250 reply not received from server.')

 

   # Send MAIL FROM command and print server response.

   # Fill in start

   # Fill in end

 

   # Send RCPT TO command and print server response.

   # Fill in start

   # Fill in end

 

   # Send DATA command and print server response.

   # Fill in start

   # Fill in end

 

   # Send message data.

   # Fill in start

   # Fill in end

 

   # Message ends with a single period.

   # Fill in start

   # Fill in end

 

   # Send QUIT command and get server response.

   # Fill in start

   # Fill in end



if __name__ == '__main__':

   smtp_client(1025, '127.0.0.1')

Expert Solution
Step 1

Actually, python is a easiest programming language.

It is a dynamically typed programming language.

trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 steps

Blurred answer
Knowledge Booster
Random Class and its operations
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education