Virtual domains + address rewriting + transport ?

2009-02-08 Thread Tony Demark

Good day.

I am have spent spent some time trying to figure out if the following  
Postfix config is possible and am hoping for some guidance.


Short Synopsis:

I would like to move some of my virtual domains to have their email  
hosted via a Google for Domains account. While there are only a  
handful of accounts, most of the accounts have many aliases and have  
used '-' as a recipient delimiter for years. As such, the actual  
number of addresses is probably in the thousands. Since Google uses  
'+' as the recipient delimiter, there is no easy way to just switch  
the domains over. I would like to use my Postfix server to filter /  
rewrite incoming addresses and then relay them on to Google, with my  
server being the MX server for the domain and using a smtp transport  
entry to direct the messages to the right place.


Long Synopsis:

I currently have several virtual domains setup similar to:

example.com example.com
m...@example.comlastname1
f...@example.comlastname1
b...@example.comlastname1
b...@example.comlastname2
b...@example.comlastname3

where my aliases are like:

lastname1   /var/boxes/lastname1/
lastname2   lastna...@example.org
lastname3   /var/boxes/lastname3/, lastna...@example.org

Since my recipient_delimeter is set to '-', this allows emails  
addressed to:


me-...@example.com
bill-baz-...@example.com

to get to the right account.

I am trying to get rid of all local delivery and have this machine  
just act a gateway that does some basic address filtering and routes  
the email to the new email server (Google for Domains). For example,  
this server would know that 'm...@example.com', 'f...@example.com' 'b...@example.com 
', and 'me-anyth...@example.com' should all be relayed to 'lastna...@example.com 
' at Google.


While I realize this doesn't work, imagine that I updated aliases to:

lastname1   lastna...@example.com

and make a transport entry:

example.com smtp:[newserver.example.google.com]

and you hopefully can get an idea of what I am trying to do.

Is something like this possible with Postfix?

Thanks.


Re: Virtual domains + address rewriting + transport ?

2009-02-08 Thread Wietse Venema
Tony Demark:
 Good day.
 
 I am have spent spent some time trying to figure out if the following  
 Postfix config is possible and am hoping for some guidance.
 
 Short Synopsis:
 
 I would like to move some of my virtual domains to have their email  
 hosted via a Google for Domains account. While there are only a  
 handful of accounts, most of the accounts have many aliases and have  
 used '-' as a recipient delimiter for years. As such, the actual  
 number of addresses is probably in the thousands. Since Google uses  
 '+' as the recipient delimiter, there is no easy way to just switch  
 the domains over. I would like to use my Postfix server to filter /  
 rewrite incoming addresses and then relay them on to Google, with my  
 server being the MX server for the domain and using a smtp transport  
 entry to direct the messages to the right place.

http://www.postfix.org/virtual.5.html
http://www.postfix.org/pcre_table.5.html

Wietse


Re: Virtual domains + address rewriting + transport ?

2009-02-08 Thread Tony Demark


On Feb 8, 2009, at 2:31 PM, Wietse Venema wrote:


Tony Demark:

I would like to move some of my virtual domains to have their email
hosted via a Google for Domains account. While there are only a
handful of accounts, most of the accounts have many aliases and have
used '-' as a recipient delimiter for years. As such, the actual
number of addresses is probably in the thousands. Since Google uses
'+' as the recipient delimiter, there is no easy way to just switch
the domains over. I would like to use my Postfix server to filter /
rewrite incoming addresses and then relay them on to Google, with my
server being the MX server for the domain and using a smtp  
transport

entry to direct the messages to the right place.


http://www.postfix.org/virtual.5.html
http://www.postfix.org/pcre_table.5.html


I tried PCREs at one point, and got close, but I kept hitting a wall  
that original left hand side of the address would get relayed to the  
new server, as opposed to the one that was specified in the virtual  
table.  For example:


virtural_regex:
/^(.*?)-(.*)@example.com$/$...@example.com

If the original server gets an email addressed to 'me- 
foo...@example.com', I need the email to be relayed to  
'm...@example.com', not 'me-foo...@example.com'.


Thanks.


Re: Virtual domains + address rewriting + transport ?

2009-02-08 Thread Wietse Venema
Tony Demark:
 
 On Feb 8, 2009, at 2:31 PM, Wietse Venema wrote:
 
  Tony Demark:
  I would like to move some of my virtual domains to have their email
  hosted via a Google for Domains account. While there are only a
  handful of accounts, most of the accounts have many aliases and have
  used '-' as a recipient delimiter for years. As such, the actual
  number of addresses is probably in the thousands. Since Google uses
  '+' as the recipient delimiter, there is no easy way to just switch
  the domains over. I would like to use my Postfix server to filter /
  rewrite incoming addresses and then relay them on to Google, with my
  server being the MX server for the domain and using a smtp  
  transport
  entry to direct the messages to the right place.
 
  http://www.postfix.org/virtual.5.html
  http://www.postfix.org/pcre_table.5.html
 
 I tried PCREs at one point, and got close, but I kept hitting a wall  
 that original left hand side of the address would get relayed to the  
 new server, as opposed to the one that was specified in the virtual  
 table.  For example:
 
 virtural_regex:
 /^(.*?)-(.*)@example.com$/$...@example.com
 
 If the original server gets an email addressed to 'me- 
 foo...@example.com', I need the email to be relayed to  
 'm...@example.com', not 'me-foo...@example.com'.

/^(.+)(-.+)?...@example\.com$/$...@example.com

Wietse


Re: Virtual domains + address rewriting + transport ?

2009-02-08 Thread Tony Demark


On Feb 8, 2009, at 4:23 PM, Wietse Venema wrote:


Tony Demark:


On Feb 8, 2009, at 2:31 PM, Wietse Venema wrote:


Tony Demark:

I would like to move some of my virtual domains to have their email
hosted via a Google for Domains account. While there are only a
handful of accounts, most of the accounts have many aliases and  
have

used '-' as a recipient delimiter for years. As such, the actual
number of addresses is probably in the thousands. Since Google uses
'+' as the recipient delimiter, there is no easy way to just switch
the domains over. I would like to use my Postfix server to filter /
rewrite incoming addresses and then relay them on to Google, with  
my

server being the MX server for the domain and using a smtp
transport
entry to direct the messages to the right place.


http://www.postfix.org/virtual.5.html
http://www.postfix.org/pcre_table.5.html


I tried PCREs at one point, and got close, but I kept hitting a wall
that original left hand side of the address would get relayed to the
new server, as opposed to the one that was specified in the virtual
table.  For example:

virtural_regex:
/^(.*?)-(.*)@example.com$/$...@example.com

If the original server gets an email addressed to 'me-
foo...@example.com', I need the email to be relayed to
'm...@example.com', not 'me-foo...@example.com'.


/^(.+)(-.+)?...@example\.com$/$...@example.com



OK ... I think I got this figured out. It ended up that the searches I  
was referencing for configuration were from 2002 ... things have  
changed somewhat since then. Combine that with a typo in a file name  
and things really start not adding up.


I started fresh with an unused domain, used only the official docs,  
and got it working. Sometimes you end up so far down the wrong path,  
it's hard to comprehend just how far you have to backtrack to right  
yourself, even if you have access to the best and brightest!


Thanks for the help.




Re: Virtual domains + address rewriting + transport ?

2009-02-08 Thread mouss
Tony Demark a écrit :
 
 On Feb 8, 2009, at 2:31 PM, Wietse Venema wrote:
 
 Tony Demark:
 I would like to move some of my virtual domains to have their email
 hosted via a Google for Domains account. While there are only a
 handful of accounts, most of the accounts have many aliases and have
 used '-' as a recipient delimiter for years. As such, the actual
 number of addresses is probably in the thousands. Since Google uses
 '+' as the recipient delimiter, there is no easy way to just switch
 the domains over. I would like to use my Postfix server to filter /
 rewrite incoming addresses and then relay them on to Google, with my
 server being the MX server for the domain and using a smtp transport
 entry to direct the messages to the right place.

 http://www.postfix.org/virtual.5.html
 http://www.postfix.org/pcre_table.5.html
 
 I tried PCREs at one point, and got close, but I kept hitting a wall
 that original left hand side of the address would get relayed to the new
 server, as opposed to the one that was specified in the virtual table. 
 For example:
 
 virtural_regex:
 /^(.*?)-(.*)@example.com$/$...@example.com
 
 If the original server gets an email addressed to
 'me-foo...@example.com', I need the email to be relayed to
 'm...@example.com', not 'me-foo...@example.com'.
 

you can test lookups using 'postmap -q'.


/^(me)-...@example\.com$/   m...@example.com

do this for all valid addresses.


If you use a wildcard like

/^([^-]+)-...@example\.com$/$...@example.com

you will break recipient validation and your postfix will accept mail
for any doesnotexist-ran...@example.com.





Re: Virtual domains + address rewriting + transport ?

2009-02-08 Thread Wietse Venema
Tony Demark:
  If the original server gets an email addressed to 'me-
  foo...@example.com', I need the email to be relayed to
  'm...@example.com', not 'me-foo...@example.com'.
 
  /^(.+)(-.+)?...@example\.com$/$...@example.com
 
 
 OK ... I think I got this figured out. It ended up that the searches I  
 was referencing for configuration were from 2002 ... things have  
 changed somewhat since then. Combine that with a typo in a file name  
 and things really start not adding up.
 
 I started fresh with an unused domain, used only the official docs,  
 and got it working. Sometimes you end up so far down the wrong path,  
 it's hard to comprehend just how far you have to backtrack to right  
 yourself, even if you have access to the best and brightest!

To make this work without false matches, you will need to enumerate
the user names.

/^(user1|user2|user3)(-.+)?...@example\.com$/$...@example.com
/^(user4|user5|user6)(-.+)?...@example\.com$/$...@example.com

False positives will cause your machine to accept spam, find out
that Google rejects the non-existent username, and then your Postfix
will try to return the spam to people who did not send it.

Wietse


Re: Virtual domains + address rewriting + transport ?

2009-02-08 Thread Tony Demark


On Feb 8, 2009, at 6:10 PM, Wietse Venema wrote:

To make this work without false matches, you will need to enumerate
the user names.

/^(user1|user2|user3)(-.+)?...@example\.com$/$...@example.com
/^(user4|user5|user6)(-.+)?...@example\.com$/$...@example.com

False positives will cause your machine to accept spam, find out
that Google rejects the non-existent username, and then your Postfix
will try to return the spam to people who did not send it.


I have the Google account set to silently drop any email whose address  
doesn't exist.


Not nearly as good as killing the message during the initial  
conversation, but at least there is no backscatter. Once things settle  
down a little, I'll probably go back and enumerate the user names.


Thanks.