我目前正在运行Ubuntu 14.04.1。我创建了一个简单的php脚本来使用mail()发送测试电子邮件,然后我从Firefox访问该脚本。我有一个VPS服务器,只有一个IP,没有域。每当我尝试发送电子邮件时,都会收到来自Google DNS的错误阻止我。我已经包含了一些文件的结果,我相信这些文件是必需的信息。
我使用的mail()是mail("myemail@gmail.com", "test", "test");
。我已经尝试添加标题信息和更详细的主题和身体信息,但这没有帮助。
/var/log/mail.log
Dec 28 22:53:04 localhost sendmail[15365]: sBT3r4qG015365: from=www-data, size=83, class=0, nrcpts=1, msgid=<201412290353.sBT3r4qG015365@localhost.localdomain>, relay=www-data@localhost
Dec 28 22:53:05 localhost sm-mta[15366]: sBT3r4F1015366: from=<www-data@localhost.localdomain>, size=370, class=0, nrcpts=1, msgid=<201412290353.sBT3r4qG015365@localhost.localdomain>, proto=ESMTP, daemon=MTA-v4, relay=localhost.localdomain [127.0.0.1]
Dec 28 22:53:05 localhost sendmail[15365]: sBT3r4qG015365: to=myemail@gmail.com, ctladdr=www-data (33/33), delay=00:00:01, xdelay=00:00:01, mailer=relay, pri=30083, relay=[127.0.0.1] [127.0.0.1], dsn=2.0.0, stat=Sent (sBT3r4F1015366 Message accepted for delivery)
Dec 28 22:53:05 localhost sm-mta[15368]: STARTTLS=client, relay=gmail-smtp-in.l.google.com., version=TLSv1/SSLv3, verify=FAIL, cipher=ECDHE-RSA-AES128-GCM-SHA256, bits=128/128
Dec 28 22:53:06 localhost sm-mta[15368]: sBT3r4F1015366: to=<myemail@gmail.com>, ctladdr=<www-data@localhost.localdomain> (33/33), delay=00:00:01, xdelay=00:00:01, mailer=esmtp, pri=120370, relay=gmail-smtp-in.l.google.com. [IPv6:2607:f8b0:400e:c04::1b], dsn=5.0.0, stat=Service unavailable
Dec 28 22:53:06 localhost sm-mta[15368]: sBT3r4F1015366: sBT3r6F1015368: DSN: Service unavailable
Dec 28 22:53:06 localhost sm-mta[15368]: sBT3r6F1015368: to=<www-data@localhost.localdomain>, delay=00:00:00, xdelay=00:00:00, mailer=local, pri=30000, dsn=2.0.0, stat=Sent
(email above has been changed to myemail@gmail.com)
的/etc/resolv.conf
nameserver 8.8.8.8
nameserver 8.8.4.4
的/ etc /主机
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
127.0.0.1 localhost.localdomain localhost servername
# Auto-generated hostname. Please do not remove this comment.
x.x.x.x servername
::1 localhost ip6-localhost ip6-loopback
127.0.0.2 servername
(servername and ip above have been changed to x.x.x.x and servername)
的/ var /线轴/邮件/ www数据
我尝试发送一封电子邮件后大约有70行,所以我会包含我认为最重要的内容。我得到了永久性的致命错误。
550-5.7.1
Our system has detected that this
message is likely unsolicited mail. To reduce the amount of spam sent
to Gmail, this message has been blocked.
我尝试了什么:
我以前访问php脚本,页面停止加载需要30秒,我会在/var/log/mail.log
收到以下错误:
Dec 29 00:35:55 localhost sendmail[15632]: My unqualified host name (servername) unknown; sleeping for retry
Dec 29 00:36:55 localhost sendmail[15632]: unable to qualify my own domain name (servername) -- using short name
要解决此问题,我将127.0.0.1
中的行/etc/hosts
行更改为现在的行。将该行更改为现在的任何更短版本会导致接收上面的错误消息并且PHP脚本将永远加载。
发送邮件时我也常常收到其他一些错误信息。我查找了问题并修复了问题,我在底部添加了127.0.0.2
行。我似乎无法通过删除该行来复制错误消息,因此可能该行不再用于某个目的。
我已尝试查看DSN: Service unavailable
中的/var/log/mail.log
,但我发现的所有内容都在更改/etc/hosts
和/etc/hostname
的内容,这些内容无效。
我读过很多关于SPF记录的文章。这似乎可能是一个贡献问题。问题是每篇文章都提到了将域名与IP相关联的问题。我没有域名,所以我不确定这是否真的很重要。他们还讨论了编辑/var/named/data/
,但/var/named
对我来说并不存在。我可以确认,如果我在Windows机器上尝试nslookup
我的IP地址,则会收到错误Non-existent domain
。这也可能与/var/spool/mail/www-data
中的错误有关。
我已经研究过我的IP是否被列入黑名单,但似乎并非如此。我最近收到了IP而且它不是共享IP,所以我不认为这是一个问题。具有讽刺意味的是,在尝试接收电子邮件的某个时刻,我确实在垃圾邮件文件夹中收到了2封邮件。我甚至不再接收垃圾邮件了。以下是其中一封电子邮件:
Delivered-To: myemail@gmail.com
Received: by 10.112.202.37 with SMTP id kf5csp1654885lbc;
Tue, 23 Dec 2014 20:55:39 -0800 (PST)
X-Received: by 10.68.200.68 with SMTP id jq4mr50110283pbc.30.1419396938944;
Tue, 23 Dec 2014 20:55:38 -0800 (PST)
Return-Path: <www-data@servername>
Received: from servername ([x.x.x.x])
by mx.google.com with ESMTPS id td7si16741093pab.130.2014.12.23.20.55.38
for <myemail@gmail.com>
(version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128);
Tue, 23 Dec 2014 20:55:38 -0800 (PST)
Received-SPF: temperror (google.com: error in processing during lookup of www-data@servername: DNS timeout) client-ip=x.x.x.x;
Authentication-Results: mx.google.com;
spf=temperror (google.com: error in processing during lookup of www-data@servername: DNS timeout) smtp.mail=www-data@servername
Received: from servername (localhost.localdomain [127.0.0.1])
by brauer (8.14.4/8.14.4/Debian-4.1ubuntu1) with ESMTP id sBO4sYfV000877
for <myemail@gmail.com>; Tue, 23 Dec 2014 23:54:34 -0500
Received: (from www-data@localhost)
by servername (8.14.4/8.14.4/Submit) id sBO4sYgK000874;
Tue, 23 Dec 2014 23:54:34 -0500
Date: Tue, 23 Dec 2014 23:54:34 -0500
From: www-data <www-data@servername>
Message-Id: <201412240454.sBO4sYgK000874@servername>
To: myemail@gmail.com
Subject: test
X-PHP-Originating-Script: 0:file.php
test
很抱歉,如果我收录了太多信息。我只是不确定一切是否相关。任何帮助,将不胜感激。感谢
答案 0 :(得分:0)
我不认为您在没有SPF和/或DKIM的情况下成功将邮件发送到Gmail,更不用说没有域名了。为什么不设置域名,或使用单独的SMTP服务器发送邮件? (例如,https://github.com/PHPMailer/PHPMailer)。或者使用Mandrill,Amazon SES,SendGrid等