Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I am trying to set up mail forwarding on a new server of mine. For example, I want emailaddress@mydomain.com to forward all email sent to it to, say, otheremail@gmail.com. I do not need/want to be able to send mail from mydomain.

I'm running Ubuntu 10.04 and it's my server so I have root access and can install/modify anything necessary. I have a few years of Linux experience, but never played with mail servers before so I literally know nothing about them. Hence, I can't really understand all the questions that have been previously asked about this topic. There also seems to be many different answers given and it would take forever to read about every solution proposed. That being said, can anyone point me in the right direction on how to accomplish this? Thank you!

share|improve this question
add comment

3 Answers

up vote 7 down vote accepted

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 mydomain = mydomain.com and mydestination = mydomain.com (replace "mydomain.com" with your actual domain). This is very important
  3. optionally in main.cf, set myhostname to something appropriate (could also be "mydomain.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: otheremail@gmail.com, this will make it so incoming email for "emailaddress@mydomain.com" get forwarded to "otheremail@gmail.com"
  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

share|improve this answer
    
Sounds pretty easy as well. I will update once my DNS admin getting the MX record needed. –  shanet Nov 8 '11 at 6:09
1  
Yeah, I forgot to mention that you need to point your domain's MX record to this server. –  Jon Lin Nov 8 '11 at 6:14
    
After failing to get sendmail working correctly, I tried using Postfix with your directions. It's working beautifully now. Thank you! –  shanet Nov 9 '11 at 1:37
add comment

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:

emailaddress@mydomain.com   otheremail@gmail.com
share|improve this answer
    
That simple huh? I contacted my DNS admin about adding the MX record and already have sendmail installed. Hopefully the MX record will be added tomorrow and I'll update then. –  shanet Nov 8 '11 at 4:52
add comment

I'm aware this thread is old, but I would appreciate elaboration: say virtualuser contains:

oneaddreess@mydomain.com   otheremail@gmail.com

Is it then possible to add:

*@mydomain.com   192.168.1.8:25

192.168.1.8 being my old outgoing server, thus redirecting the old addresses on a one by one basis.

share|improve this answer
1  
Hi Finn, I'm not a mail server expert (thus this question!) so I'm not sure, but you're much more likely to get an answer if you post a new question entirely about this and reference this question. No one will see your question here (except me since I get notifications of answers to my own questions). –  shanet Jan 30 '13 at 7:03
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.