Just a place to braindump my thoughts, talk about IT and other random stuff.
In this howto I will explain how to set up a send-only email server with Exim on Debian Linux. A sent-only email server is among other things useful for daily email reports. Cron among several other applications can sent email status reports to specified email addresses, this howto will show you how to enable this functionality on your Linux server.
It is important to note that this setup will only enable you to sent email from your server, it is not indented for receiving or relaying email from the outside and thus is not a full fledged email server setup.
First we have to download and install Exim4 and some dependencies. We will do this with the command below.
aptitude install exim4-daemon-light mailutils
After the installation is complete we will have to reconfigure Exim4. The command below will invoke some option screens. Make sure to make the right choices during the configuration or your email server will not work correctly.
dpkg-reconfigure exim4-config
You will be greeted with a welcome message. Just press ‘OK’ here.
Now you will have to choose what kind of email server you want. Choose ‘Internet site’ and press ‘OK’.
On the next screen we will have to enter our fully qualified domain name (FQDN). This is the hostname of your server (hostname.domainname.tld). Usually this is already filled in.
The next two screens will give you a bit of information on IP addresses, since we will use this email server for the purpose of sending local mail only it is a good idea to configure the mail server in a way that people from the outside cannot connect to it. We do this by letting the mail server listen on the loopback interface with the address ‘127.0.0.1’.
In the next screen we have to provide the mail server with a list of recipient domains. This is an important step so make sure you fill in the correct domain names. The list usually contains your FQDN, hostname, and local hostname entries. Mine looks like the following, make sure to substitute the FQDN and hostname with your own domain names.
lisa.isalazyadmin.net; lisa; localhost.localdomain; localhost
Next we will get the question if we want to relay mail for other domains. Just leave this field blank.
We will also get a question if we want to relay mail for other computers, leave this blank as well. It is not possible for other machines to use the mail server because it listens on the loopback interface and thus other machines cannot connect to it.
If you are asked to keep DNS queries to a minimum select ‘NO’.
Now we will have to choose between two options for email delivery. We can choose the ‘mbox’ or ‘maildir’ format. It does not really matter what you choose here but in my experience the ‘maildir’ format is supported by a broader range of applications so I choose that here.
When asked to split the Exim configuration in small files select ‘NO’.
Now that configuration is done Exim will automatically configure itself and restart for the changes to take effect. Now your email server configuration is complete! We can test the configuration by sending an email. To sent email from the command line we can do something like the following.
echo "This is a test email." | mail -s Test your@email.here
It will take a few seconds for the email to arrive at the specified email address. If you did not got anything within 5 minutes check your spam folder. If it is not in the spam folder you did something wrong and have to start from the beginning of this howto again! Just skip the step on installing Exim4 and jump right to the configure process.
If you want to receive status emails from your server on your own email account you have to edit the file ‘/etc/aliases’ to contain your email address. You can do this by opening the file in a text editor.
nano /etc/aliases
You will see something like the output below.
# /etc/aliases
mailer-daemon: postmaster
postmaster: root
nobody: root
hostmaster: root
usenet: root
news: root
webmaster: root
www: root
ftp: root
abuse: root
noc: root
security: root
root: root
In this file change the username of the ‘root’ user to your email address like below.
root: your@email.here
That’s it! You are done. Now you can receive status emails from your server on your own email address.