Posted in Communications, Technology

How to configure a send-only email server on Linux

Many server software applications, like WordPress and Nextcloud can send alerts and notifications to the system admin and to users. Email is the most universal method for sending messages, but you have to run an email server (SMTP server) on the host. Processing incoming email messages is really resource consuming, but for alerts and notification messages the host only needs to send messages, not receive them. Here is a guide for setting up exim4 email server in send-only mode on Debian 10 Linux. Configuration of exim4 on Ubuntu is similar.

Depending on how your Debian system was set up, an email server like exim, Postfix or Qmail may already be installed on your host. You can test if you already have exim4 on your system:
systemctl status exim4

If the response is active (running), you can continue to configuration. Otherwise, install exim4:
apt-get install exim4

Configuring exim4 as a send-only email server

On Debian, exim4 comes with a configuration tool that is started like this:
dpkg-reconfigure exim4-config

The first question wants to know the type of email server you would like to have. Choose (don’t worry because later, mail receive will be prevented):
Internet site; mail is sent and received directly

debian linux mail server installation

Next, you must enter a valid domain name. If you are configuring, for instance, a laptop it probably doesn’t have a top level domain name. Enter a domain name you have.

exim4 email software configuration

In this step, you can prevent exim4 from receiving any mail. Entering the localhost address tells the email server not to listen to incoming messages.
127.0.0.1

mail server setup for linux server

You can accept the suggested names: your hostname and localhost in this step. In any case, the server won’t be receiving messages.

configuration tool for exim4 mail software

This mail configuration won’t relay messages, so you can leave the relay field blank.

email routing options in exim4

Assuming the computer where you are installing the mail server has broadband connection, choose No.

exim4 email server setup on linux

This mail server won’t receive messages, but let the configuration choose the default option for mailbox format which is mbox.

mailbox type on linux

Root and Postmaster mail recipient: enter an email address that you use regularly. These messages for the root are generated by the operating system, and include alerts and notifications.

mail address for root and postmaster

The next step is to test if the mail server can send messages.

Testing and troubleshooting

A quick test for the email server can be achieved by sending a message with sendmail:
sendmail your.email@address.net
your test message is here

[Hit key combination ctrl d when you are ready to send the message]

If you don’t receive the test message to your inbox, view the log file:
/var/log/exim4/mainlog

Any error messages referring to domain names may indicate that the receiving email server wasn’t happy with your host’s domain name. Check the content of the following file:
/etc/mailname
The line should contain a valid domain name that DNS servers recognize.

The configuration file for exim4 is located here if you want to modify it manually:
/etc/exim4/update-exim4.conf.conf

NOTE: if you manually edit the configuration or mailname file, restart exim4 after saving the new configuration.

A configuration guide for Ubuntu (only minor differences) can be viewed here.

Leave a Reply

Your email address will not be published. Required fields are marked *


CAPTCHA Image