我使用以下代码:
def mailme():
print('connecting')
server = smtplib.SMTP('mail.server.com', 26)
server.connect("mail.server.com", 465)
print('connected..')
server.ehlo()
server.starttls()
server.ehlo()
server.login('scraper@server.com', "pwd")
text = 'TEST 123'
server.sendmail('me@sserver.com', 'me@server2.com', text)
server.quit()
但它给出了错误:
^{pr2}$当通过Telnet连接时,它可以工作:
~ telnet mail.zoo00ooz.com 26
Trying 1.2.3.4...
Connected to server.com.
Escape character is '^]'.
220-sh97.surpasshosting.com ESMTP Exim 4.87 #1 Mon, 01 Jan 2018 00:23:02 -0500
220-We do not authorize the use of this system to transport unsolicited,
220 and/or bulk e-mail.
^C^C
我在下面附上了使用Python3.6.0的示例邮件代码
你不需要连接两次! 正如documentation所说:
您的代码应该更像这样(即使这样,它也有点过于复杂,请参阅文档中的示例代码)
相关问题 更多 >
编程相关推荐