简体   繁体   English

从Linux服务器发送邮件时出现问题

[英]Issues Sending Mail from Linux Server

I'm currently running Ubuntu 14.04.1. 我当前正在运行Ubuntu 14.04.1。 I've created a simple php script to use mail() to send a test email and then I access the script from Firefox. 我创建了一个简单的PHP脚本,以使用mail()发送测试电子邮件,然后从Firefox访问该脚本。 I have a VPS server with a single IP and no domain. 我有一台VPS服务器,只有一个IP,没有域。 Any time I trying sending an email, I receive errors from Google DNS blocking me. 每当我尝试发送电子邮件时,都会收到来自Google DNS的错误阻止我。 I've included the results of some files, which I believe are needed information. 我已经包含了一些文件的结果,我认为这是必要的信息。

The mail() that I used is mail("myemail@gmail.com", "test", "test"); 我使用的mail()是mail("myemail@gmail.com", "test", "test"); . I've tried adding header information and more elaborate subject and body information, but that didn't help. 我尝试添加标题信息以及更详细的主题和正文信息,但这无济于事。

/var/log/mail.log /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 在/etc/resolv.conf

nameserver 8.8.8.8
nameserver 8.8.4.4

/etc/hosts / etc / hosts文件

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/spool/mail/www-data 在/ var / spool / mail中/ www数据

I get about 70 lines after attempting to send one email, so I'll include what I think is most important. 尝试发送一封电子邮件后,我收到大约70行,所以我将列出我认为最重要的内容。 I get permanent fatal errors. 我得到永久的致命错误。

 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.

What I've tried: 我试过的

I used to access the php script and it would take 30 seconds for the page to stop loading and I would receive the following errors in /var/log/mail.log : 我曾经访问过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

To fix this, I changed the line 127.0.0.1 line in /etc/hosts to what it is now. 为了解决这个问题,我将/etc/hosts 127.0.0.1行更改为现在的行。 Changing that line to any shorter version of what it is now results in receiving the error message above and the php script taking forever to load. 将该行更改为现在的任何较短版本都会导致收到上述错误消息,并且php脚本需要永久加载。

I also used to receive some other error message when sending mail. 发送邮件时,我还经常收到其他错误消息。 I looked up the issue and to fix it, I added the 127.0.0.2 line at the bottom. 我查找并修复了该问题,在底部添加了127.0.0.2行。 I can't seem to replicate the error message by removing that line anymore, so maybe that line is no longer serving a purpose. 我似乎无法通过删除该行来复制错误消息,因此该行可能不再有用。

I've tried looking into the DSN: Service unavailable in /var/log/mail.log , but all I found was changing the contents of /etc/hosts and /etc/hostname , which didn't help. 我曾尝试查看/var/log/mail.logDSN: Service unavailable ,但发现的所有内容都只是更改了/etc/hosts/etc/hostname ,但没有帮助。

I've read a lot of articles about SPF records. 我已经阅读了很多有关SPF记录的文章。 This seems like it could be an contributing issue. 看来这可能是一个有助益的问题。 The problem is every article mentions something about linking your domain to your IP. 问题是每篇文章都提到了有关将域链接到IP的内容。 I don't have a domain, so I'm not sure if this really matters. 我没有域,所以不确定这是否真的很重要。 They also talk about editing /var/named/data/ , but /var/named doesn't exist for me. 他们还谈论编辑/var/named/data/ ,但是/var/named对我不存在。 I can confirm that if I try nslookup of my IP address on my windows machine, that I get the error Non-existent domain . 我可以确认,如果我在Windows计算机上尝试nslookup IP地址,则会收到错误消息“ Non-existent domain This might also be related to the errors in /var/spool/mail/www-data . 这也可能与/var/spool/mail/www-data的错误有关。

I've looked into seeing if my IP is being blacklisted, but it doesn't seem to be. 我调查了一下我的IP是否被列入黑名单,但事实并非如此。 I recently received the IP and it's not a shared IP, so I don't think this is an issue. 我最近收到了IP,它不是共享IP,所以我认为这不是问题。 Ironically, at some point while trying to receive the emails, I did get 2 messages in my spam folder. 具有讽刺意味的是,在尝试接收电子邮件的某个时刻,我确实在垃圾邮件文件夹中收到2条消息。 I'm not even receiving them in spam anymore. 我什至不再收到垃圾邮件。 Here is one of those emails: 这是其中一封电子邮件:

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

Sorry if I included too much info. 抱歉,如果我提供了太多信息。 I'm just not sure what all is relevant. 我只是不确定所有相关的内容。 Any help would be appreciated. 任何帮助,将不胜感激。 Thanks 谢谢

I don't think you'll be successful at getting messages through to Gmail without SPF and/or DKIM, let alone without a domain. 我认为如果没有SPF和/或DKIM,您将无法成功将邮件发送到Gmail,更不用说没有域了。 Why not just set up a domain, or use a separate SMTP server to send the mail? 为什么不只是设置域,还是使用单独的SMTP服务器发送邮件? (eg, https://github.com/PHPMailer/PHPMailer ). (例如, https : //github.com/PHPMailer/PHPMailer )。 Or use Mandrill, Amazon SES, SendGrid, etc. 或使用Mandrill,Amazon SES,SendGrid等。

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

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