0% found this document useful (0 votes)
32 views2 pages

SMTP

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.

Uploaded by

Muhammad Usama
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
32 views2 pages

SMTP

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.

Uploaded by

Muhammad Usama
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 2

# Name: SMTP Plait CLient

# Purpose:

# Author: Ed Smart

# Created: 12/04/2013
# Copyright: (c) Ed 2013
# Licence: <your Licence>

• 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 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 = '<[email protected]>\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 = '<[email protected]>\r\n'
SMTPClientSocket.send(rcpttoCommand)

You might also like