我有一个运行Ubuntu14.04的DigitalOcean服务器。我在从PHP mail()函数(它在内部使用sendmail )发送电子邮件时遇到了问题。
我认为这个问题可能与我的hosts文件配置有关。下面是我目前在/etc/hosts中拥有的内容:
127.0.0.1 localhost localhost.localdomain ip-xxx-xxx-xxx-xxx
在etc/hostname中:
ip-xxx-xxx-xxx-xxx
(在上述两种情况下,我用x替换了IP地址数字)
现在我有一个指向这个服务器的域,让我们调用这个mydomain.com。
因此,当我的网站mydomain.com发送电子邮件时,电子邮件将进入垃圾邮件文件夹。我在https://www.mail-tester.com上运行了一个测试,其中一个问题是:

我尝试过将mydomain.com添加到hosts文件的上面一行,但这会导致邮件在很长一段时间后到达,或者根本没有到达。
以下是接收到的标题:
Received: from localhost.localdomain (unknown [xxx.xxx.xxx.xxx])
(using TLSv1.2 with cipher xxx (256/256 bits))
(No client certificate requested)
by mail-tester.com (Postfix) with ESMTPS id xxx
for ; Mon, 29 Apr 2019 18:35:18 +0200 (CEST)
Received: from localhost.localdomain (localhost [127.0.0.1])
by localhost.localdomain (8.15.2/8.15.2/Debian-3) with ESMTP id xxx
for ; Mon, 29 Apr 2019 17:35:18 +0100
Received: from mydomain.com (www-data@localhost)
by localhost.localdomain (8.15.2/8.15.2/Submit) with SMTP id xxx
for ; Mon, 29 Apr 2019 17:35:18 +0100有人能告诉我问题可能是什么,以及如何解决吗?
发布于 2019-05-08 09:31:14
没有人关心您的基础结构中的跃点,以及有多少本地主机被传递。但是,一定要让您的传出服务器说"Hello,I‘s mail.domain.tld“,而不是"Hello,I’s localhost.localdomain",因为没有半途而废的正确配置的服务器有兴趣与未知的邮件服务器对话。
我在引用的标题中看到,您使用postfix(1)处理出站电子邮件。查找您的main.cf中的变量D2(通常位于/etc/postfix或/usr/local/etc/postfix中)并正确地填充它。示例:myhostname=mail.domain.tld (用邮件服务器名称替换它)。还要确保smtp_banner=至少包含像smtp_banner=$myhostname ESMTP Postfix这样的$myhostname。
有关其他信息,请参见这。
https://serverfault.com/questions/965246
复制相似问题