首页 > 解决方案 > 运行python程序时出现错误550

问题描述

我正在使用免费的 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

标签: python

解决方案


推荐阅读