【问题标题】:Python SMTP Server Not Receiving EmailsPython SMTP 服务器不接收电子邮件
【发布时间】:2016-10-25 03:09:16
【问题描述】:

我尝试运行一个简单的 python SMTP 服务器,但由于某种原因,当我将它发送到服务器时它不会收到任何传入的电子邮件。我正在使用来自https://pymotw.com/2/smtpd/index.html 的以下代码:

import smtpd
import asyncore

class CustomSMTPServer(smtpd.SMTPServer):

    def process_message(self, peer, mailfrom, rcpttos, data):
        print 'Receiving message from:', peer
        print 'Message addressed from:', mailfrom
        print 'Message addressed to  :', rcpttos
        print 'Message length        :', len(data)
        return

server = CustomSMTPServer(('127.0.0.1', 25), None)

asyncore.loop()

我正在运行脚本:sudo python simpleSmtpServer.py

一些注意事项:

  • 我正在 AWS EC-2 实例上运行此脚本
  • 我知道我正确设置了我的 MX 记录;我尝试使用带有 nodejs 的 Mailin (https://github.com/Flolagale/mailin) 运行一个简单的 smtp 服务器,它能够接收和显示我发送的测试电子邮件

此代码是否缺少任何我需要更新的 DNS 配置?

【问题讨论】:

  • 127.0.0.1 仅接收本地连接(来自同一台计算机)。使用0.0.0.0 接收来自系统中所有“网卡”的连接。
  • 这是正确答案

标签: python email smtp


【解决方案1】:

@furas 给出了答案。将地址更改为 0.0.0.0 解决了问题。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2012-06-06
    • 1970-01-01
    • 2012-06-04
    • 1970-01-01
    • 2020-04-28
    • 2012-07-15
    • 2022-01-25
    • 2016-10-18
    相关资源
    最近更新 更多