python - 运行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
解决方案
推荐阅读
- keras - 如何在 keras 中使用带有 Convolution1D 层的遮罩?
- amazon-web-services - 没有 SNS 的 aws codepipeline 通知?
- php - 如何将 php 网站连接到 node.js 多人游戏
- angular - 如果 x 是 Angular 组件,则验证它在该模块中的部分
- javascript - 如何使用 Next.js Router.push 传递初始状态?
- python - NN Keras 回归:训练和预测的不同输入
- iis - 使用 ADFS 保护启用了 IIS 10 WebDav 的虚拟文件夹
- android - 如何解决“调用目标引发异常”
- github - 如何使用自定义域在 github 页面上运行几个站点
- ios - 自定义 UISwitch 设计