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 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=[] [], 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 with SMTP id qc3csp517582lbb;
        Wed, 24 Sep 2014 08:20:55 -0700 (PDT)
X-Received: by 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.
        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 [])
    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:

  1. How can I make the sendmail server to send the emails faster? What's taking so long?
  2. How can I get rid of those "personal headers" like the localhost.localdomain and the local server username?
  • sendmail really, really likes to know it's FQDN, and from the above, all it can find is localhost.localdomain, which doesn't work very well. Have you tried putting an FQDN in the hosts file, preferably first on the line with the public ip address? – MadHatter Sep 24 '14 at 16:02
  • That seems to make it faster, indeed. Also, I got it to display nice names instead of localhost, localdomain and the like. There's one more thing left: how do I get rid of this header: 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 I don't want it to send the local server user that initiated the mail sending. – Zorrocaesar Sep 25 '14 at 7:13

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 the hosts file (you can see the evidence in some of your Received: from lines). If you give sendmail an FQDN, by putting an FQDN as the first entry on the external-ip-address line of your hosts 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.

  • I just want to get rid of the line that contains the local linux account that was used to send the mail. Received: from website-test.com (www-data@localhost) This is probably set by PHP because it contains the URL of the executing script and the user that the web server is running under. – Zorrocaesar Sep 25 '14 at 7:27
  • Yes, you have said you want to do it. You haven't given a reason why - and there are a number of good reasons not to. – MadHatter Sep 25 '14 at 8:05
  • Actually, I don't want to remove it entirely. I just want to get rid of the (www-data@localhost) part. I believe there is a security problem if I expose the unix user that the webserver is running under. Here is an example header from an automated message I got from another website: Received: from CA_PRODUKTION2 ( by mail.shop-cunda.de(HeloMail 0.8.3T-R63M); Thu, 11 Sep 2014 00:05:27 +0200. There is no user in there. – Zorrocaesar Sep 25 '14 at 8:09
  • Since you are running the webserver as the standard user for your distro, and your distro can be gleaned from your web server, there's no point whatsoever in doing that. Even if you went to the effort of changing things, I'm unconvinced there is much security benefit in concealing that. What benefit do you see to it, with your current setup? The line you quote above is apples-and-oranges; your MTA doesn't put the originating user in the handoff Received: from line either, so you will need to examine other lines in the foreign email. In any case, they're running a different MTA. – MadHatter Sep 25 '14 at 8:12
  • 1
    Zorrocaesar, you still haven't given a compelling business reason for doing this. Some MTAs do (generally, the better ones) and some don't. I'm sure sendmail can be configured not to do it (it can be configured to sing the Twelve Days of Christmas); I'm sure I don't know how; I'm sure you shouldn't do it. I note that you are asking two completely separate questions under one cover. I've answered one, but have no more to say on the other; you may wish to post it as a separate question, but that is up to you. – MadHatter Sep 25 '14 at 8:16

Your Answer

By clicking "Post Your Answer", you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.