Postfix 发送电子邮件时挂起
如果我尝试按如下方式发送电子邮件,则进程会挂起并且没有任何反应:
>>> from django.core.management import setup_environ
>>> from cube import settings
>>> setup_environ(settings)
'cube'
>>> from django.core.mail import send_mail
>>> send_mail('Subject', 'Message', '[email protected]', ['[email protected]'], fail_silently=False)
但是,通过 telnet 到端口 25 工作得很好
$ telnet localhost 25
Trying ::1...
Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.
^]
telnet>
,这是以防万一
$ netstat -a | grep :smtp
tcp 0 0 *:smtp *:* LISTEN
tcp 0 0 localhost:smtp localhost:44932 ESTABLISHED
tcp 0 0 localhost:44932 localhost:smtp ESTABLISHED
tcp 0 0 localhost:smtp localhost:60964 ESTABLISHED
tcp 0 0 localhost:60964 localhost:smtp ESTABLISHED
tcp 0 0 localhost:37247 localhost:smtp FIN_WAIT2
tcp 1 0 localhost:smtp localhost:37247 CLOSE_WAIT
tcp 9 0 localhost:smtp localhost:37245 CLOSE_WAIT
我运行 Ubuntu 10.04 和 Python 2.6.5
我不知道在哪里查看接下来找出问题所在。请帮我。谢谢。
If I try to send an email as follows, the process hangs and nothing happens:
>>> from django.core.management import setup_environ
>>> from cube import settings
>>> setup_environ(settings)
'cube'
>>> from django.core.mail import send_mail
>>> send_mail('Subject', 'Message', '[email protected]', ['[email protected]'], fail_silently=False)
However, doing telnet to port 25 works just fine
$ telnet localhost 25
Trying ::1...
Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.
^]
telnet>
and here's this just in case
$ netstat -a | grep :smtp
tcp 0 0 *:smtp *:* LISTEN
tcp 0 0 localhost:smtp localhost:44932 ESTABLISHED
tcp 0 0 localhost:44932 localhost:smtp ESTABLISHED
tcp 0 0 localhost:smtp localhost:60964 ESTABLISHED
tcp 0 0 localhost:60964 localhost:smtp ESTABLISHED
tcp 0 0 localhost:37247 localhost:smtp FIN_WAIT2
tcp 1 0 localhost:smtp localhost:37247 CLOSE_WAIT
tcp 9 0 localhost:smtp localhost:37245 CLOSE_WAIT
I run Ubuntu 10.04 and Python 2.6.5
I don't know where to look next to figure out what's wrong. Please help me. Thank you.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您的邮件服务器工作不正常。当您使用
telnet
连接到它时,您应该会看到一条欢迎消息,内容如下:(您可以通过运行
postconf smtpd_banner
检查您应该看到的问候语。)您不明白这一点,因此邮件服务器未正常运行。
send_mail
可能正在等待初始消息。重新启动Postfix,并查看
/var/log/mail.*
日志文件;那里可能有一个线索可以解释为什么它不起作用。Your mail server isn't working fine. When you connect to it using
telnet
, you should see a welcome message along the lines of:(You can check the greeting that you should be seeing by running
postconf smtpd_banner
.)You don't get that, so the mail server isn't running properly.
send_mail
is probably hanging waiting for that initial message.Restart Postfix, and look in the
/var/log/mail.*
log files; there may be a clue in there as to why it's not working.