Most of programs will not accept an email using just @localhost as domain.
So, edit /etc/hosts
file to make the domain localhost.com point to your machine, including this content to the file:
127.0.0.1 localhost.com
Fedora/CentOS/RHEL: sudo yum install postfix
Ubuntu: sudo apt-get install postfix
MacOSX: Postfix is already installed by default.
-
During postfix install process, the configure text dialog will display five options:
General type of mail configuration: No configuration Internet Site Internet with smarthost Satellite system Local only
-
Select "Local Only".
-
For the domain name, use the default suggested and finish the install.
Enabling this, you can use any email address ending with "@localhost" or "@localhost.com".
Example: here, my unique account is [email protected]. But while testing systems, I can use any address like [email protected], [email protected], etc, because all will be redirected to [email protected]
- If not exists, create file /etc/postfix/virtual:
sudo nano /etc/postfix/virtual
- Add the following 2 lines content, replacing
<your-user>
with your Unix user account:
@localhost <your-user>
@localhost.com <your-user>
- Save and close the file.
- Configure postifx to read this file:
- Open /etc/postfix/main.cf:
sudo nano /etc/postfix/main.cf
- And check if this line is enabled, or add it if not exists:
virtual_alias_maps = hash:/etc/postfix/virtual
- Open /etc/postfix/main.cf:
- Activate it:
sudo postmap /etc/postfix/virtual
- Reload postfix:
sudo systemctl restart postfix
- If you're under non
systemd
distro, like Ubuntu 14.04, service restart command probably is:sudo service postfix reload
Ubuntu: sudo apt-get install thunderbird
- Skip the welcome screen (click in the button to use existing accounts);
- Click in the Settings button at top right (similar to Chrome settings) then click on Preferences > Account Settings
- Under Account Actions choose "Add Other Account"
- Select "Unix Mailspool (Movemail)"
- Your account will be
<your-user>@localhost
(of course, replace<your-user>
with your user account). Don't use<your-user>@(none)
, use<your-user>@localhost
- Ingoing and Outgoing server will be:
localhost
- Restart (close and reopen) Thunderbird.
- This step have two purposes: test your install and stop the
Unable to locate mail spool file.
message. - Using Thunderbird, send new email to
<your-user>@localhost
, replacing<your-user>
with your user account - Click on "Get Mail"
- Test catch-all: send new email to
averagejoe@localhost
- Click on "Get Mail" and you'll see the message at
Inbox
.
Works great. I really liked the instructions, very easy to set up. I was glad I found this as, I thought it might be tricky and with these instructions it was a few minutes on each machine.
I tried it on a desktop and a server.
Server
On the server, which only has a CLI, I wound up using mail instead of T-bird, installed via sudo apt-get install mailutils
It can be tested by sending a message to yourself by using...
mail -s "test" (your user name)@localhost
It works great to get the CRON messages on the machine.
Just type mail and you get a CLI email list. mail basics are, q to quit, m to compose, enter and spacebar to move through messages. Entering question mark ?, brings up command help.
Desktop Install
One gotcha that caught me is that I already had T-bird installed and therefore it had a default SMTP server already. For me this required what I would call step 6A to add a local STMP server.
6A. In the pane above "Account Actions" scroll, using the bar to the bottom "Outgoing Server (SMTP)".
Click Add
For description I wrote Local SMTP
Server Name: localhost
Port: 25
Username : (the user name)@localhost
Authentication Method: Password, transmitted insecurely
Connection Security: None
Then I went back into the account settings for the mail set up in step 6 and set the Outgoing Server (SMTP) to the Local SMTP
Also in /etc/hosts you can put in localhost.com as a alias and it works fine, like this...
127.0.0.1 localhost localhost.com