Forward incoming mail on Linux server?

I prefer postfix, it's easier to configure and by default, most things are turned off:

  1. Install postfix.
  2. 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

  3. Optionally in main.cf, set myhostname to something appropriate (could also be "example.com")
  4. 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).

  5. 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.)
    
  6. 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]"

  7. Save main.cf and run this command: postalias /etc/aliases (or /etc/mail/aliases or whatever it was in main.cf).
  8. Start postfix: sudo /etc/init.d/postfix start

Here is some more info for postfix on ubuntu: https://help.ubuntu.com/community/Postfix


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]