I have a small server (Ubuntu 14.04) for multiple websites. One of these websites needs to send emails to the user on various actions (registration, password recovery, etc.). I have sendmail installed and I'm able to send mail from PHP scripts.
I have configured a SFP DNS entry.
I server's hostname is "rubber".
My /etc/hosts file contains
127.0.0.1 localhost localhost.localdomain rubber
public.ip.address rubber
With this configuration, sending email takes very long (about 20 seconds). Also, the sendmail log (/var/log/mail.log) show a line like this:
Sep 24 17:28:52 server sendmail[19842]: s8OFSLUd019842: to=<user@gmail.com>, 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)
The received mail headers look like this (I've changed real addresses):
Delivered-To: user@gmail.com
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: <no-reply@website.com>
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 <user@gmail.com>
(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 no-reply@website.com 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 no-reply@website.com designates 2022:4ff0:51:500::16e as permitted sender) smtp.mail=no-reply@website.com
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 <user@gmail.com>; 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 <user@gmail.com>; Wed, 22 Sep 2014 17:20:25 +0200
X-Authentication-Warning: localhost.localdomain: www-data owned process doing -bs
Message-ID: <b93f252bb2ce76f36dfa4b2c71f3a094@website-test.com>
Date: Wed, 22 Sep 2014 17:20:09 +0200
Subject: Test email
From: "Website.com" <no-reply@website.com>
To: user@gmail.com
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: quoted-printable
My questions are:
- How can I make the sendmail server to send the emails faster? What's taking so long?
- How can I get rid of those "personal headers" like the localhost.localdomain and the local server username?
Best Answer
The per-connection delay is caused by sendmail wanting to look up its own fully-qualified domain name (FQDN), which failing all else it does by trying to reverse-resolve its external IP address. You haven't given it an FQDN, so it's trying to get by with
localhost.localdomain
, which it gleaned from the localhost entry in thehosts
file (you can see the evidence in some of yourReceived: from
lines). If you give sendmail an FQDN, by putting an FQDN as the first entry on the external-ip-address line of yourhosts
file, it should speed up all operations.As for removing some of those
Received: from
lines, they are added as an RFC requirement each time the message passes from one sphere of control to another. Do you have a very good business reason for wanting to get rid of them? Because if you don't - and usually, even if you do - it's a really bad idea to mess with them.