Sometimes it’s necessary to change the hostname or the reverse DNS of a server. When altering these settings without some care this will result in some issues. This article shows you what you should consider.
In this article we assume the old hostname was oldhost.slopjong.de and the new will be newhost.slopjong.de
Old hostname still in the email header Received
Before we change the hostname and reverse DNS let’s have a look at what information an email client in general sees.
When clicking on an email in Thunderbird you’ll see the actual email text. If you want to see more details just click on
Other Actions > View Source.
Now you’ll see something that looks like the following block.
Received: from lusi.example.com by lusi.example.com (Dovecot) with LMTP id mGnEDHVwAIfwNDAOgxpbQ8 for ; Mon, 25 Mar 2013 10:37:11 +0100 X-policyd-weight: using cached result; rate:hard: -5.5 Received: from oldhost.slopjong.de (oldhost.slopjong.de [220.127.116.11]) by lusi.example.com (Postfix) with ESMTP id 9C27E1222FC0 for ; Mon, 25 Mar 2013 10:37:10 +0100 (CET) Received: by oldhost.slopjong.de (Postfix, from userid 0) id 8D9F52F9C87D1; Mon, 25 Mar 2013 10:37:09 +0100 (CET) To: email@example.com Subject: Mo oder Mi
At the bottom are the email headers To and Subject and above a couple of Received headers which tell you what path your email exactly took through the internet from the sender to the destination server.
To get the trace you have to follow from the bottom up to the top. This means, start reading with the third Received header in line 9, then read the second in line 6 and finally have a look at the first one in line 2.
Every Received entry contains the hostname of the server which is processing your email. In this case it got firstly processed by oldhost.slopjong.de and then twice by lusi.example.com.
Now if you decide to change the hostname in
/etc/hostname and also change the reverse DNS you expect to have
oldhost.slopjong.de changed to
newhost.slopjong.de in the second Received header.
Unfortunately if you only edit
/etc/hostname then your old and new hostname will appear both in the Received headers.
... Received: from oldhost.slopjong.de (newhost.slopjong.de [18.104.22.168]) by lusi.example.com (Postfix) with ESMTP id 9C27E1222FC0 for
; Mon, 25 Mar 2013 10:37:10 +0100 (CET) ...
The reason is that Postfix keeps a variable with your hostname in its configuration file
/etc/postfix/main.cf that you forgot to edit. To fix it just open this configuration file and change the line with the variable
hostname. Afterwrads you have to restart postfix by executing
when using System V scripts or for systemd
systemctl start postfix.service