Encouraged in the comments by Gilles, I have adapted and expanded another answer:
(I am running Ubuntu 12.04.1 LTS, but the general setup process should apply to previous and future Ubuntus)
The first thing to do is to install a Mail Transfer Agent (MTA) so the mail can be relayed to a mail User Agent (MUA) such as
Thunderbird. This is only necessary because we are dealing with local mail and want to be able to send and receive it; with normal remote gmail type accounts, only a user agent such as
Thunderbird is necessary.
postfix, which itself is an alternative to
sendmail, of which there are commercial and open source versions. More information about postfix's capabilities is at the official site and users may find that the mailing lists contain useful information if any issues arise.
So, to install the program, run
sudo apt-get install postfix
You can either configure it when it is installed, or decline the offer and later run
sudo dpkg-reconfigure postfix
to create the important config file (
/etc/main.cfg). If you ever manually edit this file, which is not necessarily recommended, you must run
sudo newaliases and
sudo service postfix restart afterwards to apply the changes.
Postfix is pretty straightforward to setup, although you may have some particular settings that you wish to apply. In the first screen you see below, you must choose the local option for your mail:
Then on the next screen choose your 'mail name'; it is usually the same as
/etc/hostname. You can accept the defaults for most of the following screens.
When it mentions
/etc/aliases and the Root and Postmaster recipient (as above), you can fill in your user name, but make sure you check your aliases file is as it should be by reading the next section of this tutorial.
First, as also recommended in this discussion, your
/etc/aliases should be like this if it is setup correctly:
If not, edit it with
sudo nano /etc/aliases, and then run
sudo newaliases and
sudo service postfix restart so that the configuration is updated.
Postfix's aliases feature allows mail to be redirected, so the setup is very important for the rest of this tutorial.
As also noted in the above link, you need to create a
.forward file containing your username and localhost: e.g.
mike@localhost so that root's mail will be forwarded to you. To do this, enter these commands:
sudo touch /root/.forward
and then run
sudo nano /root/.forward
to place your user: e.g.
mike@localhost in the file and save it.
In addition, I found it was necessary to add your user to the mail group so that
Thunderbird could access the mail files:
sudo adduser $USER mail
and then logout and login for the changes to take effect. There is no need to
chmod any files, as some articles might suggest, and adding your user to the mail group is much better practice and avoids any direct changing of the permissions on the root filesystem.
Now for the
Thunderbird configuration. Go to edit > account settings > account actions > add other account > select Unix spoolmail and in the next screen put your username in the first box and place
yourusername@localhost in the second box.
Now, go to your new account in account settings and select server settings and select the local directory as
/var/mail/username (if setup), as in the screenshot below.
As per the instructions in this article you will need to configure the smtp server if you want to test the account by sending a mail to
root@localhost and then clicking get mail in Thunderbird to receive it, as root's mail is being redirected to
Go to account settings > outgoing server and choose to add a new one. The settings should be as in the screenshot below:
Now, finally test your account by composing a mail to
root@localhost and then a few seconds later clicking get mail on your account. You should see an email like this:
Some programs or logs will need to be configured so that they send mail to root, but that can be decided as you find the need. This article should hopefully be useful as it is not always straightforward to set up
Thunderbird to receive local mail.