#file name:PA01_3.py
#writer:Zhang_Jingtun(Ordinary_Crazy)
#initial date:20180310
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 =('smtp.163.com', 25)
# Create socket called clientSocket and establish a TCP connection with mailserver
#Fill in start
clientSocket = socket(AF_INET, SOCK_STREAM)
clientSocket.connect(mailserver)
#Fill in end
recv = clientSocket.recv(1024)
print (recv)
if(str(recv[:3],"utf-8") != "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)
print (recv1)
if(str(recv1[:3],"utf-8") != '250'):
print ('250 reply not received from server.')
loginCommand = 'AUTH LOGIN\r\n'
clientSocket.send(loginCommand.encode())
recv7 = clientSocket.recv(1024)
print (recv7)
if str(re
计算机网络(2)——手动SMTP
最新推荐文章于 2024-10-31 20:19:43 发布