Download as txt, pdf, or txt
Download as txt, pdf, or txt
You are on page 1of 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 = '<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)

You might also like