0

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=<[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)

The received mail headers look like this (I've changed real addresses):

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

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?
2
  • 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, 2014 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 <[email protected]>; Wed, 22 Sep 2014 17:20:25 +0200 I don't want it to send the local server user that initiated the mail sending. Sep 25, 2014 at 7:13

1 Answer 1

1

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.

6
  • 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. Sep 25, 2014 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, 2014 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 (10.40.20.12) by mail.shop-cunda.de(HeloMail 0.8.3T-R63M); Thu, 11 Sep 2014 00:05:27 +0200. There is no user in there. Sep 25, 2014 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, 2014 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, 2014 at 8:16

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .