简体   繁体   English

在Ubuntu上未通过Python通过本地主机发送电子邮件

[英]Email not being sent via localhost with Python on Ubuntu

I have the following simple code to send an email: 我有以下简单的代码可以发送电子邮件:

server = smtplib.SMTP('localhost')
server.set_debuglevel(1)
server.sendmail(fromaddr, toaddrs, msg)
server.quit()

However the message never gets sent. 但是,该消息永远不会发送。 I added the "set_debuglevel" line in an attempt to troubleshoot but the output doesn't mean much to me: 我添加了“ set_debuglevel”行以尝试进行故障排除,但是输出对我而言意义不大:

send: 'ehlo [127.0.1.1]\r\n'
reply: '250-ubuntu\r\n'
reply: '250-PIPELINING\r\n'
reply: '250-SIZE 10240000\r\n'
reply: '250-VRFY\r\n'
reply: '250-ETRN\r\n'
reply: '250-STARTTLS\r\n'
reply: '250-ENHANCEDSTATUSCODES\r\n'
reply: '250-8BITMIME\r\n'
reply: '250 DSN\r\n'
reply: retcode (250); Msg: ubuntu
PIPELINING
SIZE 10240000
VRFY
ETRN
STARTTLS
ENHANCEDSTATUSCODES
8BITMIME
DSN
send: 'mail FROM:<info@foobarconsulting.com> size=337\r\n'
reply: '250 2.1.0 Ok\r\n'
reply: retcode (250); Msg: 2.1.0 Ok
send: 'rcpt TO:<adam@foobarconsulting.com>\r\n'
reply: '250 2.1.5 Ok\r\n'
reply: retcode (250); Msg: 2.1.5 Ok
send: 'data\r\n'
reply: '354 End data with <CR><LF>.<CR><LF>\r\n'
reply: retcode (354); Msg: End data with <CR><LF>.<CR><LF>
data: (354, 'End data with <CR><LF>.<CR><LF>')
send: 'Hello!\r\n\r\nThe below URLs are either broken or taking too long to respond:\r\nhttp://www.google.com/does-not-exist/\r\nhttp://www.cnn.com/does-not-exist\r\n\r\nLog in and navigate to http://blahblah.com/wp-admin to update the content.\r\n\r\nThanks,\r\n\r\nYour friends at Foo Bar Consulting\r\n.\r\n'
reply: '250 2.0.0 Ok: queued as E7B8820144\r\n'
reply: retcode (250); Msg: 2.0.0 Ok: queued as E7B8820144
data: (250, '2.0.0 Ok: queued as E7B8820144')
send: 'quit\r\n'
reply: '221 2.0.0 Bye\r\n'
reply: retcode (221); Msg: 2.0.0 Bye

I have installed postfix (I believe it was installed by default when I set up my Ubuntu with the standard LAMP packages) but I don't know where else to go for help. 我已经安装了postfix(我相信在使用标准LAMP软件包设置Ubuntu时默认安装了postfix),但是我不知道还有什么地方可以寻求帮助。

Any insight or ideas would be greatly appreciated. 任何见解或想法将不胜感激。

  1. you might want to check out sendmail's log 您可能想查看sendmail的日志

  2. make sure your local DNS works. 确保您的本地DNS有效。 try ping foobarconsulting.com 尝试ping foobarconsulting.com

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM