Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
Some Postfix beginner questions!
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Networking & Security
View previous topic :: View next topic  
Author Message
Gentoo Server
Apprentice
Apprentice


Joined: 21 Jul 2003
Posts: 279

PostPosted: Wed Jul 12, 2006 8:31 pm    Post subject: Some Postfix beginner questions! Reply with quote

How can I forward with postfix all mails to *@foo.com to test@bar.com?
Back to top
View user's profile Send private message
DNAspark99
Guru
Guru


Joined: 03 Sep 2004
Posts: 321

PostPosted: Wed Jul 12, 2006 9:21 pm    Post subject: Reply with quote

/etc/postfix/main.cf:
Code:
header_checks = regexp:/etc/postfix/header_checks


/etc/postfix/header_checks:
Code:

IF /^To:/
/(.*)@foo\.com$/ REDIRECT test@bar.com
ENDIF


I *just* figured this out, but for my needs, anything NOT addressed to a specific domain (*@foo.com) had to be redirected to a catchall account (userX@foo.com), and despite what the documentation was implying, I just couldn't get the negative(^!) regex to work until I put it in the IF/ENDIF:

Code:
IF /^To:/
!/(.*)@foo\.com$/ REDIRECT userX@foo.com
ENDIF
Back to top
View user's profile Send private message
Gentoo Server
Apprentice
Apprentice


Joined: 21 Jul 2003
Posts: 279

PostPosted: Thu Jul 13, 2006 3:29 pm    Post subject: Reply with quote

Are the outgoing mails from localhost unaffected from these rewrites?
Back to top
View user's profile Send private message
DNAspark99
Guru
Guru


Joined: 03 Sep 2004
Posts: 321

PostPosted: Thu Jul 13, 2006 4:58 pm    Post subject: Reply with quote

The first example:

Code:

IF /^To:/
/(.*)@foo\.com$/ REDIRECT test@bar.com
ENDIF


should only redirect if it's addressed "To *@foo.com" - so mail to anywhere else, including localhost, should still reach the proper reciepients, yes. You can easily write a similar rule for them if you'd like tho.
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Networking & Security All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum