运行python程序时出现错误550

时间:2019-10-12 13:52:46

标签: python

我正在使用免费的SMTP服务器,端口为25,服务器为“ localhost”。当我使用filename.py从终端运行程序时,等待一段时间后出现错误。我收到的错误是状态代码550-无效的收件人。我100%确定siddarth@csu.fullerton.edu是有效的电子邮件。为什么会出现此错误?

from socket import *
import ssl
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', 25)
#Fill in start #Fill in end
clientSocket = socket(AF_INET,SOCK_STREAM)

# Create socket called clientSocket and establish a TCP connection with mailserver
#Fill in start
#Fill in end
clientSocket.connect(mailserver)
recv = clientSocket.recv(1024).decode()
print(recv)
if recv[:3] != '220':
 print('220 reply not received from server.')
 print(recv)
# Send HELO command and print server response.
heloCommand = 'HELO Alice\r\n'
clientSocket.send(heloCommand.encode())
recv1 = clientSocket.recv(1024).decode()
print(recv1)
if recv1[:3] != '250':
 print('250 reply not received from server.')
 print(recv1)




# Send MAIL FROM command and print server response.


print("Hello my name is siddarth krishnan")





clientSocket.send('Mail FROM: <krishnan_gurusamy@yahoo.com>\r\n')
print(recv1)
recv1 = clientSocket.recv(1024)


print('After the mail command this is the response' + recv1)

# Fill in start
# Fill in end


clientSocket.send('RCPT TO: <siddarth@csu.fullerton.edu>\r\n')


recv1 = clientSocket.recv(1024)

print('After recipet command' + recv1)


clientSocket.send('DATA\r\n')
recv1 = clientSocket.recv(1024)
print('After data command' + recv1);



clientSocket.send(msg)
clientSocket.send(endmsg)

# Message ends with a single period.
clientSocket.send('.\r\n') # sends period, then blank line
recv1 = clientSocket.recv(1024)
print("After sending data command" + recv1)
clientSocket.send('QUIT\r\n')
clientSocket.close()
# Send RCPT TO command and print server response.
# Fill in start
# Fill in end
# Send DATA command and print server response.
# Fill in start
# Fill in end
# Send message data.
# Fill in start
# Fill in end
# Message ends with a single period.
# Fill in start
# Fill in end
# Send QUIT command and get server response.
# Fill in start
# Fill in end

0 个答案:

没有答案