我必须用Python编写一个用于类的SMTP邮件客户端,并且在作业的第一部分中卡住了。在经历了很多麻烦之后,我已经走到了这一步(目前使用免费的便携式SMTP服务器,但以后将需要使用SSL或TLS用于gmail)。下面是我的代码。我得到一个500语法错误,当它到达RCPT到代码的一部分。有人能帮忙吗?from socket import *
msg = "\r\n I love computer networks!"
endmsg = "\r\n.\r\n"
# Choose a mail server
mailServer = 'localhost'
mailPort = 25
# Create socket called clientSocket and establish a TCP connection with mailserver
clientSocket = socket(AF_INET,SOCK_STREAM)
clientSocket.connect((mailServer, mailPort))
recv = clientSocket.recv(1024)
print 'test'
print recv
if recv[:3] != '220':
print '220 reply not received from server.'
# Send HELLO command and print server response.
helloCommand = 'HELO Alice\r\n';
clientSocket.send(helloCommand)<