Question

SMTP Your task is to develop a simple mail client that sends email to any recipient....

SMTP 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, we will not be using this module in this lab, because it hide the details of SMTP and socket programming. In order to limit spam, some mail servers do not accept TCP connection 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 a AOL mail server. 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 e-mail as junk. Make sure you check the junk/spam folder when you look for the e-mail sent from your client. What to Hand in In your submission, you are to provide the complete code for your SMTP mail client as well as a screenshot showing that you indeed receive the e-mail message. Skeleton Python Code for the Mail Client from socket import * msg = ”\r\n I love computer networks!” endmsg = ”\r\n.\r\n” # Choose a mail server (e.g. Google mail server) and call it mailserver mailserver = #Fill in start #Fill in end # Create socket called clientSocket and establish a TCP connection with mailserver #Fill in start #Fill in end recv = clientSocket.recv(1024) 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) recv1 = clientSocket.recv(1024) 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 Optional Exercises 1. Mail servers like Google mail (address: smtp.g mail.com, port: 587) requires your client to add a Transport Layer Security (TLS) or Secure Sockets Layer (SSL) for authentication and security reasons, before you send MAIL FROM command. Add TLS/SSL commands to your existing ones and implement your client using Google mail server at above address and port. 2. Your current SMTP mail client only handles sending text messages in the email body. Modify your client such that it can send emails with both text and images.

0 0
Add a comment Improve this question Transcribed image text
Answer #1

from socket import *

msg = ”\r\n I love computer networks!”

endmsg = ”\r\n.\r\n”

# Choose a mail server (e.g. Google mail server) and call it mailserver

Mailserver =’localhost’

Mailport = 7890

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

SMTPClientSocket = socket(AF_INET,SOCK_STREAM)

SMTPClientSocket.connect((Mailserver, Mailport))

recv = clientSocket.recv(1024)

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)

recv1 = clientSocket.recv(1024)

print recv1

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

print '250 reply not received from server.'

# Send MAIL FROM command and print server response.

mailfromCommand =’alice@gapes.fr\r\n’

SMTPClientSocket.send(mailfromCommand)

recv1 = clientSocket.recv(1024)

print recv1

if recv1[:3]! = ‘250’:

print ‘250 reply not received from server.’

# Send RCPT TO command and print server response.

rcpttoCommand = ‘<gifted@my.easternct.edu>\r\n’

SMTPClientSocket.send(rcpttoCommand)

recv1 = clientSocket.recv(1024)

print recv1

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

print ‘250 reply not received from server.’

# Send DATA command and print server response.

dataCommand = ‘Data’

print dataCommand

SMTPClientSocket.send(dataCommand)

recv1 = clientSocket.recv(1024)

print recv1

if recv1[:3] != ‘250’:

print ‘250 reply not received from server.’

#Send message data.

message = raw_input(‘Enter Message Here: ’)

#Message ends with a single period.

mailMessageEnd = ‘\r\n.\r\n’

SMTPClientSocket.send(message+ mailMessageEnd)

print recv1

if recv1[:3] != ‘250’:

print ‘250 reply not received from server.’

#Send QUIT command and get server response.

quitCommand = ‘Quit\r\n’

print quitCommand

SMTPClientSocket.send(quitCommand)

recv1 = clientSocket.recv(1024)

print recv1

if recv1[:3] != ‘250’:

print ‘250 reply is not received from server.’

pass

if name==’main’:

main()

Add a comment
Know the answer?
Add Answer to:
SMTP Your task is to develop a simple mail client that sends email to any recipient....
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • In Python, make changes in the client code, so that the client allows the user to...

    In Python, make changes in the client code, so that the client allows the user to continue to send multiple requests until the user types in “Quit”. This means that the client process should not exit after the user sends one request and receives one response. Instead, the client process should be able to receive subsequent inputs from the user. You need to have a loop in the client code, so that it can accept the user request until the...

  • Here is the description of the client and server programs that you need to develop in C using TCP: Suppose we have a simple student query system, where the server keeps student's info in an array...

    Here is the description of the client and server programs that you need to develop in C using TCP: Suppose we have a simple student query system, where the server keeps student's info in an array of struct student_info ( char abc123171 char name [101 double GPA; To simplify the tasks, the server should create a static array of 10 students with random abc123, name, and GPA in the server program. Then the server waits for clients. When a client...

  • Java(Eclipse). The task will create a server and client and send a message from the client...

    Java(Eclipse). The task will create a server and client and send a message from the client to the server. We will have two classes NetworkClient and NetworkServerListener classes. These will each have a main to run from the command line The NetworkServerListener class will listen for a client connection from NetworkClient , receive a message, display the message to the console (stdout) and exit. The NetworkClient class will create a connection to the NetworkServerListener and send a message to the...

  • In this lab you will write a simple chat application in Python using TCP sockets. The...

    In this lab you will write a simple chat application in Python using TCP sockets. The chat application consists of a chat server and a chat client. At any one time, the chat server is communicating with just one chat client. When the client and the server are done chatting, they exchange end messages which ends the session. The client and server read and write Unicode strings using the readUTF() and writeUTF() methods of DataInputStream and DataOutputStream respectively. After compilation,...

  • implement the follwing code using command promp or Eclipse or any other program you are familiar with. keep the name of...

    implement the follwing code using command promp or Eclipse or any other program you are familiar with. keep the name of the classes exatcly the same as requested for testing purpose. please follow each instruction provided below Objective of this assignment o get you famililar with developing and implementing TCP or UDP sockets. What you need to do: I. Implement a simple TCP Client-Server application 2. and analyze round trip time measurements for each of the above applications 3. The...

  • I need help with my IM (instant messaging) java program, I created the Server, Client, and...

    I need help with my IM (instant messaging) java program, I created the Server, Client, and Message class. I somehow can't get both the server and client to message to each other. I am at a roadblock. Here is the question below. Create an IM (instant messaging) java program so that client and server communicate via serialized objects (e.g. of type Message). Each Message object encapsulates the name of the sender and the response typed by the sender. You may...

  • Need help with this code in C Write your own simple client/server set of processes. The...

    Need help with this code in C Write your own simple client/server set of processes. The client should use a shared memory segment to send a command message to the server. The server process should monitor the shared memory segment, and respond as follows: "HI" - - The server prints "Greetings" to the screen. "PID" - - The server prints it's process id to the screen. "QUIT" - - The server terminates gracefully, detaching and releasing the shared memory segment....

  • Using the programming language of your choice, write a client application which: Connects to a network...

    Using the programming language of your choice, write a client application which: Connects to a network service, then Asks for version information, then Receives the response, then Disconnects and Prints out the response. Detail: The program will take no input from the user. When your program is executed, it should connect to IP address 64.183.98.170 on port 3800. Upon successful connection, send the string: version\n where \n is an end of line marker. The server will respond with a string...

  • Project Description In this project, you will be developing a multithreaded Web server and a simple...

    Project Description In this project, you will be developing a multithreaded Web server and a simple web client. The Web server and Web client communicate using a text-based protocol called HTTP (Hypertext Transfer Protocol). Requirements for the Web server The server is able to handle multiple requests concurrently. This means the implementation is multithreaded. In the main thread, the server listens to a specified port, e.g., 8080. Upon receiving an HTTP request, the server sets up a TCP connection to...

  • Q7 The following Client side Java code can send a message to the server side via...

    Q7 The following Client side Java code can send a message to the server side via UDP socket. The client side Java code and the server side Java code are running in two different hosts respectively. The server side host name is “MyFileServer”. The server side receives the message and converts all the letters in the message received to uppercase, then sends the modified message back to the client side. Please read the code carefully, and fill out the blanks...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT