View previous topic :: View next topic |
Author |
Message |
Gentoo Server Apprentice
Joined: 21 Jul 2003 Posts: 279
|
Posted: Wed Jul 12, 2006 8:31 pm Post subject: Some Postfix beginner questions! |
|
|
How can I forward with postfix all mails to *@foo.com to test@bar.com? |
|
Back to top |
|
|
DNAspark99 Guru
Joined: 03 Sep 2004 Posts: 321
|
Posted: Wed Jul 12, 2006 9:21 pm Post subject: |
|
|
/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 |
|
|
Gentoo Server Apprentice
Joined: 21 Jul 2003 Posts: 279
|
Posted: Thu Jul 13, 2006 3:29 pm Post subject: |
|
|
Are the outgoing mails from localhost unaffected from these rewrites? |
|
Back to top |
|
|
DNAspark99 Guru
Joined: 03 Sep 2004 Posts: 321
|
Posted: Thu Jul 13, 2006 4:58 pm Post subject: |
|
|
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 |
|
|
|