我有一台小型服务器(Ubuntu 14.04),用于多个网站。其中一个网站需要在用户执行各种操作(注册、密码恢复等)时向用户发送电子邮件。我安装了 sendmail,并且能够通过 PHP 脚本发送邮件。
我已配置 SFP DNS 条目。我的服务器的主机名为“rubber”。我的 /etc/hosts 文件包含
127.0.0.1 localhost localhost.localdomain rubber
public.ip.address rubber
使用此配置,发送电子邮件需要很长时间(大约 20 秒)。此外,sendmail 日志(/var/log/mail.log)显示如下行:
Sep 24 17:28:52 server sendmail[19842]: s8OFSLUd019842: to=<[email protected]>, delay=00:00:15, xdelay=00:00:15, mailer=relay, pri=30370, relay=[127.0.0.1] [127.0.0.1], dsn=2.0.0, stat=Sent (s8OFSbcl019844 Message accepted for delivery)
收到的邮件头如下所示(我已更改真实地址):
Delivered-To: [email protected]
Received: by 10.112.136.195 with SMTP id qc3csp517582lbb;
Wed, 24 Sep 2014 08:20:55 -0700 (PDT)
X-Received: by 10.180.99.195 with SMTP id es3mr12425233wib.67.1411572055732;
Wed, 24 Sep 2014 08:20:55 -0700 (PDT)
Return-Path: <[email protected]>
Received: from localhost.localdomain ([2022:4ff0:51:500::16e])
by mx.google.com with ESMTPS id el1si7235041wid.69.2014.08.22.08.20.55
for <[email protected]>
(version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128);
Wed, 24 Sep 2014 08:20:55 -0700 (PDT)
Received-SPF: pass (google.com: domain of [email protected] designates 2022:4ff0:51:500::16e as permitted sender) client-ip=2022:4ff0:51:500::16e;
Authentication-Results: mx.google.com;
spf=pass (google.com: domain of [email protected] designates 2022:4ff0:51:500::16e as permitted sender) [email protected]
Received: from localhost.localdomain (localhost.localdomain [127.0.0.1])
by localhost.localdomain (8.14.4/8.14.4/Debian-4.1ubuntu1) with ESMTP id s8OFKPU7019505
for <[email protected]>; Wed, 22 Sep 2014 17:20:40 +0200
Received: from website-test.com (www-data@localhost)
by localhost.localdomain (8.14.4/8.14.4/Submit) with SMTP id s8OFKAOG019503
for <[email protected]>; Wed, 22 Sep 2014 17:20:25 +0200
X-Authentication-Warning: localhost.localdomain: www-data owned process doing -bs
Message-ID: <[email protected]>
Date: Wed, 22 Sep 2014 17:20:09 +0200
Subject: Test email
From: "Website.com" <[email protected]>
To: [email protected]
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: quoted-printable
我的问题是:
- 如何让 sendmail 服务器更快地发送电子邮件?为什么这么久才发送?
- 我怎样才能摆脱那些“个人标头”,例如 localhost.localdomain 和本地服务器用户名?
答案1
每个连接的延迟是由于 sendmail 想要查找自己的完全限定域名 (FQDN),而它尝试反向解析外部 IP 地址,但失败了。您没有为其指定 FQDN,因此它尝试使用 ,它是localhost.localdomain
从文件中的 localhost 条目中收集的hosts
(您可以在某些Received: from
行中看到证据)。如果您通过将 FQDN 作为文件 external-ip-address 行中的第一个条目,为 sendmail 指定 FQDN,hosts
则应该可以加快所有操作的速度。
至于删除其中的一些Received: from
行,每次消息从一个控制范围传递到另一个控制范围时,它们都会作为 RFC 要求添加。您是否有很好的商业理由想要摆脱它们?因为如果您不这样做 - 通常,即使您这样做 - 弄乱它们也是一个非常糟糕的主意。