On a Debian-based system you should already have exim4 which provides the sendmail utility. Configure it as follows:
1. Confirm FQDN
exim4 requires a "fully qualified" domain name for your local machine, which just means it needs a dot in it. Confirm this with the following:
$ hostname
$ hostname --fqdn
These will return your machine name and your FQDN. By default your FQDN is exactly the same as your machine name and does not contain a dot, and you need to change it.
(If it is different and contains a dot, skip step 2.)
2. Modify hosts file
We will now set your FQDN. To do this modify your hosts file:
sudo nano /etc/hosts
You should see the following lines in the file (gaps are tabs):
127.0.0.1 localhost
127.0.1.1 HOSTNAME
change this to...
127.0.0.1 localhost
127.0.1.1 mail.localhost HOSTNAME
...then save and exit. Repeat step one to confirm that your hostname remains the same, and your FQDN has been updated.
3. Configure exim4
Configure exim4 as follows:
sudo dpkg-reconfigure exim4-config
In the questions that follow select the following options (and otherwise select the defaults):
- "local delivery only; not on a network"
- System mail name: "mail.localhost"
- Other destinations for which mail is accepted: "mail.localhost"
- Keep number of DNS queries minimal? Yes
- Delivery method: mbox format in /var/mail
- Where to send
root and postmaster mail: USERNAME@localhost
- Now system messages will be sent to your user account and you don't need special permissions to access them
4. Test
To test, you can send a local email with mail USERNAME@localhost. Fill in the prompts as follows
$ mail USERNAME@localhost
Cc: <leave blank, hit enter>
Subject: test subject
test body <hit enter>
<hit Ctrl-D>
You can confirm the message has been received by typing mail. Hit Q to quit the text-based mail client.
5. Configure MUA GUI
Now configure your preferred GUI client for mbox access, and check that your test message also appears in your inbox there.