This document contains code for an SMTP client program with comments describing its purpose, author, and creation date. It connects to a mail server, sends HELLO, MAIL FROM, and RCPT TO commands, and prints the server responses to validate the commands were accepted. The client is designed to send a simple message from one email address to another.
This document contains code for an SMTP client program with comments describing its purpose, author, and creation date. It connects to a mail server, sends HELLO, MAIL FROM, and RCPT TO commands, and prints the server responses to validate the commands were accepted. The client is designed to send a simple message from one email address to another.
This document contains code for an SMTP client program with comments describing its purpose, author, and creation date. It connects to a mail server, sends HELLO, MAIL FROM, and RCPT TO commands, and prints the server responses to validate the commands were accepted. The client is designed to send a simple message from one email address to another.
• 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 maiLser 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 HELLO command and print server response. helloCommand = 'HELLO Alice\r\n' clientSocket.send(helloCommand) recvl = clientSocket.recv(1024) print recvl if recvl[:3] I= '250': print '250 reply not received from server.' # Send MAIL FROM command and print server response. mailfromCommand = '<alice@crepes.fr>\r\n' SMTPClientSocket.send(mailfromCommand) recvl = clientSocket.recv(1024) print recvl if recvl[:3] != '250': print '250 reply not received from server.' # Send RCPT TO command and print server response. rcpttoCommand = '<smarted@my.easternct.edu>\r\n' SMTPClientSocket.send(rcpttoCommand)