从sendmail函数发送邮件时如何避免“收到:(来自root @ localhost)”?

时间:2017-01-27 06:20:45

标签: php linux ubuntu sendmail

它通过了SPF和DKIM,但Gmail仍然将其标记为垃圾邮件。 我注意到电子邮件标题中有类似的内容:

Received: (from root@localhost) by mydomain.com (8.15.2/8.15.2/Submit) id v0R4tOqT009065; Fri, 27 Jan 2017 04:55:24 GMT

当我在命令行中发送邮件时会发生这种情况。如果有人访问网站时由PHP发送,则会更改为from www-data@localhost

如何将其更改为实际的发件人地址? 这是完整的标题:

Delivered-To: xxx@gmail.com
Received: by 10.12.176.77 with SMTP id l13csp74374qvc;
        Thu, 26 Jan 2017 20:55:28 -0800 (PST)
X-Received: by 10.99.101.193 with SMTP id z184mr7291389pgb.216.1485492928174;
        Thu, 26 Jan 2017 20:55:28 -0800 (PST)
Return-Path: <root@mydomain.com>
Received: from mydomain.com (mydomain.com. [45.76.111.24])
        by mx.google.com with ESMTPS id 20si3316577pfu.287.2017.01.26.20.55.27
        for <xxx@gmail.com>
        (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128);
        Thu, 26 Jan 2017 20:55:27 -0800 (PST)
Received-SPF: pass (google.com: domain of root@mydomain.com designates 45.76.111.24 as permitted sender) client-ip=45.76.111.24;
Authentication-Results: mx.google.com;
       dkim=pass header.i=@mydomain.com;
       spf=pass (google.com: domain of root@mydomain.com designates 45.76.111.24 as permitted sender) smtp.mailfrom=root@mydomain.com
Received: from mydomain.com (mydomain.com [45.76.111.24]) by mydomain.com (8.15.2/8.15.2/Debian-4) with ESMTP id v0R4tO19009066 for <    xxx@gmail.com>; Fri, 27 Jan 2017 04:55:25 GMT
DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=mydomain.com; s=default; t=1485492925; bh=ftnjnh4sfzHQMJKMVUjQsNdbl/+WlV83iWkmffs8/  Bs=; h=Date:To:Subject:From:From; b=mQavJF62btZ7izrNljK+P0alo4vZMOi2hcDo7I0kW+XmlP+uxGEXEfxaX8nYxY9KX
     SOvibSqC62F+BUeVLeWyBp8qAFtN3/uvTxQNif83ZAYny/KNlhBDo3VcCq2XrY8lj7
     ERI+nUknfaSCP1Z3m/F2M7YxBRlXhQEnSqSeDI/Q=
Received: (from root@localhost) by mydomain.com (8.15.2/8.15.2/Submit) id v0R4tOqT009065; Fri, 27 Jan 2017 04:55:24 GMT
Date: Fri, 27 Jan 2017 04:55:24 GMT
Message-Id: <201701270455.v0R4tOqT009065@mydomain.com>
To: xxx@gmail.com
Subject: test email
From: noreply@mydomain.com

/etc/hosts我有:

45.76.111.24    mydomain.com mydomain.com
127.0.0.1       localhost localhost.localdomain
127.0.1.1       guest

mydomain.com也是我的主机名。

2 个答案:

答案 0 :(得分:0)

检查/etc/hostname,您在那里看到了什么?

答案 1 :(得分:0)

你可以设置&#34; From&#34;您的Php代码中的smtp标头。如果您正在使用Php邮件功能,请查看&#34;其他标题&#34; Php邮件功能的参数:http://php.net/manual/en/function.mail.php

您的电子邮件标头未显示任何问题。您可以尝试将电子邮件从垃圾邮件文件夹手动移动到收件箱。