Hostname and (Apple) Mail Server Dependencies

My Mac Mini with OSX Server had this thing that the hostname (as displayed in the Terminal app) would change after a reboot. Something that annoyed me tremendously. Thankfully there are several (Terminal) commands to change the hostname (back) to its 'original name'.

Since I wanted to change my hostname PERMANENTLY, I used the following command:

sudo scutil –set HostName new_hostname

This worked perfectly. Or so I thought.

Today I noticed that my mail app wasn't showing new emails from my SabNZBd services. Investigating the logfiles with Splunk showed that incoming mail was refused (you could also use the logging window in the Mail part of the Server Admin Tool, or the Console app). Not only from the localhost, but also from external mailservers on the Internet.

Jun 29 09:55:28 zeus postfix/smtp[1506]: BB2F9567BB36: to=<**********@zeus.***>, orig_to=<willem@*******.com>, relay=none, delay=1923, delays=1923/0.06/0/0, dsn=4.4.1, status=deferred (connect to 127.0.0.1[127.0.0.1]:10024: Connection refused)

Googling around with this error message showed that the amavis deamon (amavisd) might not be running. A Splunk search revealed this to be true. The amavisd was not able to start.

amavisd reports invalid hostnameLooks like the permanent hostname change I did, disabled some server functionality. Googling around the Interwebs showed that the variable ($myhostname) in the amavisd config file (/etc/amavisd.conf) should be set.

Open the /etc/amavisd.conf file and search for the following line:

# $myhostname = 'mail.example.com'; # must be a fully-qualified domain name!

And replace the mail.example.com for the fully qualified domain name of the server and remove the '#' at the beginning on the line. After that you can restart the mail services and mail will come pouring in.

Stopping the mail server from the Terminal app:

$ sudo serveradmin stop mail

Starting the mail server from the Terminal app:

$ sudo serveradmin start mail

Or just use the Server Admin tool.

Posted on June 29, 2011 and filed under Apple, Internet, Tips'n Tricks.