Forward incoming mail on Linux server?
Solution 1:
I prefer postfix, it's easier to configure and by default, most things are turned off:
- Install postfix.
In /etc/postfix/main.cf set these two options
mydomain = example.com mydestination = example.com
Replace "example.com" with your actual domain. This is very important
- Optionally in main.cf, set
myhostname
to something appropriate (could also be "example.com") Add this line somewhere in main.cf:
local_transport = error:local delivery is disabled
this turns off local transport so email delivery to local users are turned off (you can skip this is you want local users to receive email).
In main.cf, make sure you have this line (there should be lots of variations that have been commented out):
alias_maps = hash:/etc/aliases # (or `hash:/etc/mail/aliases`, etc.)
Now edit the
/etc/aliases
(or/etc/mail/aliases
or whatever it was in main.cf) and create the alias:emailaddress: [email protected]
, this will make it so incoming email for "[email protected]" get forwarded to "[email protected]"- Save main.cf and run this command:
postalias /etc/aliases
(or/etc/mail/aliases
or whatever it was in main.cf). - Start postfix:
sudo /etc/init.d/postfix start
Here is some more info for postfix on ubuntu: https://help.ubuntu.com/community/Postfix
Solution 2:
Do you already have a functioning incoming mail server? Have you setup MX records for you domain yet?
- Set up mx records in DNS
- Install sendmail
Set up /etc/mail/virtusertable
with the following forwarding line:
[email protected] [email protected]