我发送的很多电子邮件都被退回

我发送的很多电子邮件都被退回

我正在运行 Ubuntu 10.04 LTS 服务器和 Amazon EC2。刚刚启动了社区,安装了 apache2、php5、sendmail……就这些。

配置中没有更改任何内容。昨晚我向大约 2000 名收件人发送了一份新闻稿。

mail.log 显示邮件已被接受并进行传递,如下所示:

Jan 27 16:40:42 ip-10-48-213-66 sendmail[24725]: p0RGefNE024725: [email protected], ctladdr=www-data (33/33), delay=00:00:01, xdelay=00:00:01, mailer=relay, pri=67364, relay=[127.0.0.1] [127.0.0.1], dsn=2.0.0, stat=Sent (p0RGefKv024726 Message accepted for delivery)

但它似乎像这样被反弹:

Jan 27 16:40:42 ip-10-48-213-66 sm-mta[24728]: p0RGefKv024726: to=<[email protected]>, ctladdr=<[email protected]> (33/33), delay=00:00:01, xdelay=00:00:00, mailer=esmtp, pri=157483, relay=smtp.zoovienna.at. [83.64.127.201], dsn=4.0.0, stat=Deferred: 450 4.1.8 <[email protected]>: Sender address rejected: Domain not found

或这个

Jan 27 20:13:39 ip-10-48-213-66 sm-mta[10058]: p0RH5QCC032505: to=<[email protected]>, ctladdr=<[email protected]> (33/33), delay=03:08:13, xdelay=00:00:01, mailer=esmtp, pri=1777483, relay=mx00.kundenserver.de. [212.227.15.150], dsn=4.0.0, stat=Deferred: 421 invalid sender domain 'ip-10-48-213-66.eu-west-1.compute.internal' (misconfigured dns?)

或这个

Jan 27 20:13:39 ip-10-48-213-66 sm-mta[10058]: p0RH2CUw031458: to=<[email protected]>, ctladdr=<[email protected]> (33/33), delay=03:11:27, xdelay=00:00:00, mailer=esmtp, pri=1777483, relay=mxzhb.bluewin.ch. [195.186.18.144], dsn=4.0.0, stat=Deferred: 451 MAIL FROM: <[email protected]> Unable to verify MX-Record for domain ip-10-48-213-66.eu-west-1.compute.internal

总是多次并且仍在运行......

我注意到那里/etc/mail/trusted-users是空的。不过电子邮件似乎已经发出去了,所以应该没问题。

/etc/mail/local-host-names好像

localhost
ip-10-48-213-66.eu-west-1.compute.internal

现在,如果我使用以下 php 命令发送邮件:

var_dump(mail('[email protected]','subject!','body!','From: [email protected]','-f [email protected]'));

我收到以下邮件:

Delivered-To: [email protected]
Received: by 10.42.219.8 with SMTP id hs8cs55591icb;
        Fri, 28 Jan 2011 03:28:51 -0800 (PST)
Received: by 10.213.35.209 with SMTP id q17mr4059475ebd.53.1296214129940;
        Fri, 28 Jan 2011 03:28:49 -0800 (PST)
Return-Path: <[email protected]>
Received: from ip-10-48-213-66.eu-west-1.compute.internal (flimmit.com [79.125.4.119])
        by mx.google.com with ESMTPS id u13si41731903eeh.3.2011.01.28.03.28.20
        (version=TLSv1/SSLv3 cipher=RC4-MD5);
        Fri, 28 Jan 2011 03:28:49 -0800 (PST)
Received-SPF: pass (google.com: best guess record for domain of [email protected] designates 79.125.4.119 as permitted sender) client-ip=79.125.4.119;
Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of [email protected] designates 79.125.4.119 as permitted sender) [email protected]
Received: from ip-10-48-213-66.eu-west-1.compute.internal (localhost [127.0.0.1])
    by ip-10-48-213-66.eu-west-1.compute.internal (8.14.3/8.14.3/Debian-9.1ubuntu1) with ESMTP id p0SBRYQF000694
    for <[email protected]>; Fri, 28 Jan 2011 11:27:34 GMT
Received: (from www-data@localhost)
    by ip-10-48-213-66.eu-west-1.compute.internal (8.14.3/8.14.3/Submit) id p0SBRYCv000693;
    Fri, 28 Jan 2011 11:27:34 GMT
Date: Fri, 28 Jan 2011 11:27:34 GMT
Message-Id: <201101281127.p0SBRYCv000693@ip-10-48-213-66.eu-west-1.compute.internal>
X-Authentication-Warning: ip-10-48-213-66.eu-west-1.compute.internal: www-data set sender to [email protected] using -f
To: [email protected]
Subject: subject!
X-PHP-Originating-Script: 1000:test.php
From: [email protected]

body!

我还注意到发送邮件需要很长时间,我知道如果解析地址有问题,这将是一个问题。

我的 sendmail 路径未在 php.ini 中配置,但 php info 显示以下内容应该是正确的:/usr/sbin/sendmail -t -i

这是一封来自新闻通讯工具(phplist)的电子邮件,它已发送并且未显示 x-authentication-warning 标头。

我能以某种方式修复这个问题吗?或者有没有办法识别谁收到了邮件,谁没有收到,以便我可以重新发送?

任何帮助都值得感激。

更新:

我刚刚注意到邮件工具可能没有设置 -f 参数。我修复了这个问题。现在本地地址仍然显示,但 golem 等专业列表的其他电子邮件也存在同样的情况。

因此,在上面的电子邮件中,我使用了 -f 参数。现在这样可以吗,还是仍然有问题?

答案1

您的 sendmail 配置错误。它使用内部 EC2 域名 ip-10-48-213-66.eu-west-1.compute.internal 作为发件人域,由于无法查找和检查该域名,因此电子邮件被拒绝。您需要在其中输入一个实际的真实互联网域名,该域名可以反向 DNS 查找您发送邮件的 IP 地址 - 您必须向 Amazon 申请从 EC2 发送电子邮件的权限,以便他们为您配置反向 DNS。

无论如何,从 EC2 服务器发送电子邮件可能很棘手,因为许多 EC2 IP 地址都在黑名单中。您最好研究一下亚马逊刚刚推出的全新简单电子邮件服务。

答案2

检查谁收到了您的电子邮件的一个好方法是使用标题为每个收件人生成一个唯一的退回地址Return-Path,这样您就可以解析退回的邮箱并逐一匹配将电子邮件退回给您的人。

我看到您正在使用 EC2,确实不建议直接从 EC2 运行您的邮件服务,因为传递率非常低且不稳定(这正是您的问题),我在使用 EC2 时也遇到了这个问题,我刚刚决定与外部 SMTP 提供商签约以解决所有传递率和退回问题,它足够便宜,值得花费,特别是在如此低的数量下。

我正在使用 AuthSMTP (http://www.authsmtp.com/),它们价格便宜,而且非常可靠。

答案3

当我执行以下步骤时,我解决了这个问题:

# vi /etc/mail/sendmail.mc

MASQUERADE_AS(domain.com)dnl
FEATURE(masquerade_envelope)dnl
FEATURE(masquerade_entire_domain)dnl
MASQUERADE_DOMAIN(domain.com)dnl

# m4 /etc/mail/sendmail.mc > /etc/mail/sendmail.cf

# yum install sendmail-cf

# /etc/init.d/sendmail restart

相关内容