Friday, July 31, 2009

Configure postfix to send emails for root to your account

Goal: make our small ubuntu server forward email which has "to: root" to your private mail.

Install postfix.
sudo apt-get install postfix
Some console app for sending emails can be handy too:
sudo apt-get install mutt
Edit /etc/postfix/main.cf. In mydestination enter host, host.domain, localhost.domain, and also empty domain:
mydestination = serverek.przepompownia.com, localhost.przepompownia.com, , localhost
Restart postfix. I'm not sure if it is really needed, but won't hurt ;)
sudo /etc/init.d/postfix restart
Ok, now edit /etc/aliases. Add something like this:
root: franek
franek: mickey@my.mail.com
Dont forget to run:
sudo newaliases
This way everything sent to root is forwarded to franek, and everything sent to franek is forwarded to mickey@my.mail.com

Now you can try sending some mail to "root". You can use mutt for this.
UPDATE:
Recently my ISP (neostrada, TPSA) blocked outgoing connections to port 25 (standard port for connecting with SMTP servers). What to do to send emails to port 587 is well described here. Author only forgot to add that you also need this:
transport_maps = hash:/etc/postfix/transport
in your main.cf

No comments: