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 would like to configure postfix to catch all emails an redirect them to a specific email address. All emails except those send to a domain.

eg. catch all mails except those sent to domain @dom1.com; redirect them to my@address.com;

e1@example.com                -> my@address.com
e2@other_example.com          -> my@address.com
e3@dom1.com                   -> e3@dom1.com
e4@dom1.com                   -> e4@dom1.com
anything_else@any.com         -> my@address.com

on centos

my@address.com should not be on same server as postfix (eg. it should be my_addr@google.com)

share|improve this question
    
Run a dummy nameserver which only knows about dom1.com? –  symcbean Jan 27 '12 at 11:45
    
You run the risk of receiving a ton of spam if you do this, as some spam bots will try to send email to lots of common-names@example.com –  Bryan Jan 27 '12 at 11:57
    
it is a testserver. no spam there. I'd setup a dummy nameserver, but there are also testsites there. thanks –  costelr Jan 27 '12 at 13:25
add comment

2 Answers

Postfix has an always_bcc configuration directive where you can specify a single address to direct copies of all your mail to. You can set it to an address which is local to your mail server and use Procmail for more specific filtering and forwarding. Procmail supports regular expressions so you should have no trouble matching your addresses and domains. There is an abundance of recipes and examples for procmail configurations on the web.

share|improve this answer
    
thanks. I do not need a bcc, but a full redirect; this is a test server and I don't want, for instance, to send (by mistake) thousands of mails to clients; –  costelr Jan 27 '12 at 14:40
    
@costelr I see, so this is a misunderstanding - I assumed you would need the forwarding for archival purposes. You should work with virtual maps as suggested by Adamo then. –  syneticon-dj Jan 27 '12 at 15:04
add comment

An answer to a similar question previously on SF suggests the use of a virtual map.

share|improve this answer
    
thanks adamo. I've added /.*@dom1.com/ myaccount in my virtual file for postfix. This redirects all emails from @dom1.com to myaccount. But how do I let this emails go, and redirect only all the others to myaccount? –  costelr Jan 27 '12 at 13:21
    
in fact myaccount should be a gmail account (not just an account on server) –  costelr Jan 27 '12 at 13:27
    
I am not an expert on postfix as I do most of my stuff with sendmail. However I suspect that you can make a virtual map that does what you want. –  adamo Jan 28 '12 at 16:56
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.