If the postfix has been installed, then run the following command to reconfigure
sudo dpkg-reconfigure postfix
Answer the question as the following:
- General type of mail configuration: Internet Site
- System mail name: test.com Can be any domain, even a fake one.
- Root and postmaster mail recipient: ubuntu the login user in ubuntu system that you have created
- Other destinations to accept mail for (blank for none): $myhostname, test.com, localhost.localdomain, , localhost
- Force synchronous updates on mail queue? No
- Local networks: 127.0.0.0/8 [::ffff:127.0.0.0]/104 [::1]/128
- Use procmail for local delivery? Yes
- Mailbox size limit (bytes): 0
- Local address extension character: +
- Internet protocols to use: all
Edit the postfix config file to point to virtual file:
vi /etc/postfix/main.cf
Set this value
virtual_alias_maps = hash:/etc/postfix/virtual
Edit the virtual addresses with the following command:
sudo vi /etc/postfix/virtual
Add the following entries:
contact@test.com ubuntu
admin@test.com ubuntu
Then run the following command:
postmap /etc/postfix/virtual
Lastly restart postfix.
To debug and find out what happen when you send mail with this command
echo "Test mail" | mail -s "Test" ltest@yahoo.com
tail -f /var/log/mail.log
tail -f /var/log/mail.err