Re: Redirect all mail from one domain to the same u...@otherdomain?

2009-02-12 Thread Jeff Weinberger

Mouss wrote:

Jeff Weinberger a �crit :
 [snip]

 This is helpful, but I still need the query to take all the other
 alias domains into account. So, I need the IF condition, or a  
second map.



I don't think so. I used this. I don't remember the details, but the
idea is that you can often get rid of flow control (if, ...) using
additional tables.


Thanks - yes, additional tables, maps, etc. would make the sql coding  
far simpler.




 Thank you for your help...it's informative as always!

 if the wildcard alias will produce the result I need then this is
 resolved.


@example.org @example.com

works, but smtpd will accept mail to anyth...@...
(virtual_alias_maps are used for recipient validation during the smtp
transaction). if all addresses are valid (catchall or whatver), this  
is
ok. otherwise, it's bad. in any case, you must make sure that mail  
isn't

bounced after it is accepted (queued). This is what happens by default
(after virtual alias expansion, a delivery error occurs, and an NDR is
generated).


Thank you - this will work well. I'll use a catchall mailbox to make  
sure that I don't generate an NDR.


thanks for your help!





Re: Redirect all mail from one domain to the same u...@otherdomain?

2009-02-11 Thread mouss
Jeff Weinberger a écrit :
 [snip]
 
 This is helpful, but I still need the query to take all the other
 alias domains into account. So, I need the IF condition, or a second map.
 

I don't think so. I used this. I don't remember the details, but the
idea is that you can often get rid of flow control (if, ...) using
additional tables.

 Thank you for your help...it's informative as always!
 
 if the wildcard alias will produce the result I need then this is
 resolved.
 

@example.org@example.com

works, but smtpd will accept mail to anyth...@example.org
(virtual_alias_maps are used for recipient validation during the smtp
transaction). if all addresses are valid (catchall or whatver), this is
ok. otherwise, it's bad. in any case, you must make sure that mail isn't
bounced after it is accepted (queued). This is what happens by default
(after virtual alias expansion, a delivery error occurs, and an NDR is
generated).


Re: Redirect all mail from one domain to the same u...@otherdomain?

2009-02-10 Thread mouss
jeff_homeip a écrit :
 [snip]
 
 that creates some complications...and might be too difficult
 

a script and a Makefile... or sql as below:

 but why not use wildcard virtual aliases? You noted below that they break 
 recipient 
 validations. Do you mean that smtp_recipient_restrictions won't work? at all 
 or parts?
 

no, it's not about smtpd restrictions. it's about rejecting mail to
invalid recipients.

 Wildcard virtual aliases seems like the best waybut I want to understand 
 the implications 
 on everything esle before I proceed.
 
 Thanks!
 
 The reason is that if you use
 @example.com @example.org
 then this breaks recipient validation: smtpd will accept
 anything^example.com, then at delivery time, the user won't be found and
 a bounce will be generated. in short, you become a source of backscatter
 (you send bounces to innocents whose addresses were forged by spammers)
 
 Unless I don't bounce unknown addresses
 

and you'd do what with these? if you have a catchall, it's ok. but you
should not discard mail (people do mistype addresses some time, so it's
not just spammers trying invalid addresses).

 you can generate the individual mappings with a script. alternatively,
 if you store users in sql, you can use sql statements to generate these
 on the fly. examples have been posted multiple times to the list (a
 long time ago, that said, but you may be lucky...).


 
 it would be something like:
 
 if (%d='domain1.com') then select %...@domain2..com from virtual_alias else 
 select alias 
 from virtual_alias where address=%s 
 
 (that's not quite right in the syntax, but you get the idea). This wont' 
 work, as I'd have to 
 write a special select clause for each domain I want to work this way.
 


assuming you have a User table containing valid email addresses and a
AliasDomain table containing (alias, destination) domains:

select User.user from AliasDomain, User where
 AliasDomain.alias = '%d'
AND
 User.user = CONCAT('%u', '@', AliasDomain.destination)

you can avoid the CONCAT inside the search if you split your emails in
(user, domain) columns like I do. in which case, the query becomes

select CONCAT(User.user, '@', User.domain) where
AliasDomain.alias = '%d'
AND
AliasDomain.destination = User.domain
AND
User.user = '%u'


of course, this works for 1 depth alias domains (it doesn't work if
example.net is an alis for example.org which is in turn an alias of
example.com). but this should be enough in most cases.



Re: Redirect all mail from one domain to the same u...@otherdomain?

2009-02-10 Thread Jeff Weinberger

jeff_homeip a écrit :

[snip]
 that creates some complications...and might be too difficult



a script and a Makefile... or sql as below:

 but why not use wildcard virtual aliases? You noted below that they  
break

recipient
 validations. Do you mean that smtp_recipient_restrictions won't  
work? at all

or parts?



no, it's not about smtpd restrictions. it's about rejecting mail to
invalid recipients.

 Wildcard virtual aliases seems like the best waybut I want to  
understand

the implications
 on everything esle before I proceed.

 Thanks!


 The reason is that if you use
 @example.com @example.org
 then this breaks recipient validation: smtpd will accept
 anything^example.com, then at delivery time, the user won't be  
found and
 a bounce will be generated. in short, you become a source of  
backscatter
 (you send bounces to innocents whose addresses were forged by  
spammers)


 Unless I don't bounce unknown addresses




and you'd do what with these? if you have a catchall, it's ok. but you
should not discard mail (people do mistype addresses some time, so  
it's

not just spammers trying invalid addresses).


I use a catchall for some domains instead of rejecting unknown
recipients, for exactly that reason. I find about 2-3% of catchall mai
is user errors (like mis-spellings) rather than spam.

So in this case, I can use a wildcard catchall.

So an alias map of:

@domain1.tld   @domain2.tld

will produce the expected result of anyuser @ domain1.tld being
redirected to the same user (anyuser) @ domain2.tld?

That would be by far the easiest to do in my setup.




you can generate the individual mappings with a script.

alternatively,

if you store users in sql, you can use sql statements to generate

these
on the fly. examples have been posted multiple times to the list  
(a

long time ago, that said, but you may be lucky...).




it would be something like:

if (%d=3D'domain1.com') then select %...@domain2..com from

virtual_alias else select alias

from virtual_alias where address=3D%s

(that's not quite right in the syntax, but you get the idea). This

wont' work, as I'd have to
write a special select clause for each domain I want to work this  
way.





assuming you have a User table containing valid email addresses and a
AliasDomain table containing (alias, destination) domains:

select User.user from AliasDomain, User where
AliasDomain.alias =3D '%d'
AND
User.user =3D CONCAT('%u', '@', AliasDomain.destination)

you can avoid the CONCAT inside the search if you split your  
emails in

(user, domain) columns like I do. in which case, the query becomes

select CONCAT(User.user, '@', User.domain) where
AliasDomain.alias =3D '%d'
AND
AliasDomain.destination =3D User.domain
AND
User.user =3D '%u'


of course, this works for 1 depth alias domains (it doesn't work if
example.net is an alis for example.org which is in turn an alias of
example.com). but this should be enough in most cases.


This is helpful, but I still need the query to take all the other
alias domains into account. So, I need the IF condition, or a second  
map.


Thank you for your help...it's informative as always!

if the wildcard alias will produce the result I need then this is
resolved.





--

Jeff Weinberger
http://disruptivemarketing.jeffweinberger.com






Re: Redirect all mail from one domain to the same u...@otherdomain?

2009-02-09 Thread jeff_homeip
--- In postfix-us...@yahoogroups.com, Victor Duchovni
victor.ducho...@... wrote:

 On Sun, Feb 08, 2009 at 09:50:16PM -0800, Jeff Weinberger wrote:

 
  I am trying to figure out the best way to map one domain to
another with
  the same users...precisely the behavior I am trying to achieve is:
when
  mail is sent (from outside, or from another user within my postfix
  installation) to u...@... I want it redirected to u...@...
  - in otherwords, the user is preserved, but the domain is
  translated/rewritten. To be more specific:
 
  us...@... gets re-routed to us...@...
  us...@... gets re-routed to us...@...

 - Are you looking to rewrite just the envelope recipient, or also
message
   From/To/Cc headers?

It's only important to rewrite the envelope sender. The result I want
is that the message is delivered to *...@domain2.tld - if it has the
original To/Cc header that's fine, and probably desireable.


 - Is all mail first passed through an SMTP content_filter?

Yes. All mail coming from outside my server is passed through
amavisd-new for spam/virus checking. Mail originating from my server
is passed through a specialized content filter. (via the submission
service)

It is important that this rewrite apply to messages coming from
outside as well as those originating on my server.


 - Are all the original and rewritten recipients delivered to another
host
   via SMTP, or is some of the mail delivered locally (local,
virtual, ...)?

I'm not completely sure this answers your question, but the message
may be only to u...@domain1.tld or to a number of addresses including
u...@domain1.tld. Only the copy of the message to u...@domain1.tld
should get rerouted to u...@domain2.tld.

both domain1.tld and domain2.tld are mine and my postfix instance is
the MX for them. domain1.tld is an alias domain and domain2.tld is a
virtual domain.



 
  My initial guess is to use recipient_canonical_maps and use a pcre
map:
 
  /^(.*)@domain1.tld/   {$1)@domain2.tld

 This guess is wrong for many reasons, but I think it best to first
 understand what problem you are really trying to solve, before we
 tear apart the wrong answer to potentially the wrong question.

Thank you...but I would also like to know if I can impose on your
time, what is wrong with this - it will help me better solve this and
future problems.


  I don't see a way to achieve this with alias_maps and
header_checks (with
  action REDIRECT) would miss messages sent to u...@... where that is
  not the To: or Cc: address (such as list mail).

 This is worse.

That I understood. Thanks.


  Really, I am just checking with experts more knowledgeable than I
whether I
  have chosen a good (or the best) way to achieve this, or if there
is a
  better way.

 Yes, there is a correct way of solving your problem, but first describe
 your problem in more detail.

Does that help? Please let me know if there is any more detail I can
provide.

Thank you for your help!




 --
   Viktor.

 Disclaimer: off-list followups get on-list replies or get ignored.
 Please do not ignore the Reply-To header.

 To unsubscribe from the postfix-users list, visit
 http://www.postfix.org/lists.html or click the link below:
 mailto:majord...@...?body=unsubscribe%20postfix-users

 If my response solves your problem, the best way to thank me is to not
 send an it worked, thanks follow-up. If you must respond, please put
 It worked, thanks in the Subject so I can delete these quickly.





Re: Redirect all mail from one domain to the same u...@otherdomain?

2009-02-09 Thread mouss
jeff_homeip a écrit :
 --- In postfix-us...@yahoogroups.com, Victor Duchovni
 victor.ducho...@... wrote:
 On Sun, Feb 08, 2009 at 09:50:16PM -0800, Jeff Weinberger wrote:

 I am trying to figure out the best way to map one domain to
 another with 
 the same users...precisely the behavior I am trying to achieve is:
 when 
 mail is sent (from outside, or from another user within my postfix 
 installation) to u...@... I want it redirected to u...@... 
 - in otherwords, the user is preserved, but the domain is 
 translated/rewritten. To be more specific:

 us...@... gets re-routed to us...@...
 us...@... gets re-routed to us...@...
 - Are you looking to rewrite just the envelope recipient, or also
 message
   From/To/Cc headers?
 
 It's only important to rewrite the envelope sender. 

you mean the envelope recipient. if so, use virtual_alias_maps. however,
don't use wildcard virtual aliases. instead, generate one mapping for
each user:

us...@example.com   us...@example.org
...


The reason is that if you use
@example.com@example.org
then this breaks recipient validation: smtpd will accept
anything^example.com, then at delivery time, the user won't be found and
a bounce will be generated. in short, you become a source of backscatter
(you send bounces to innocents whose addresses were forged by spammers)

you can generate the individual mappings with a script. alternatively,
if you store users in sql, you can use sql statements to generate these
on the fly. examples have been posted multiple times to the list (a
long time ago, that said, but you may be lucky...).


 The result I want
 is that the message is delivered to *...@domain2.tld - if it has the
 original To/Cc header that's fine, and probably desireable.
 

so you want virtual_alias_maps (yes, these apply to _all_ domains. don't
confuse with virtual_alias_domains).

 - Is all mail first passed through an SMTP content_filter?
 
 Yes. All mail coming from outside my server is passed through
 amavisd-new for spam/virus checking. Mail originating from my server
 is passed through a specialized content filter. (via the submission
 service)
 

you must disable rewrite except in one smtpd in a chain. see the FILTER
README (look for no_address_mappings) or amavisd-new README.postfix.

if you don't, then virtual aliases will be expanded twice (before and
after the filter), which may result in duplicate mail (think of a foo
- foo, bar, which becomes foo - foo, foo, bar if expanded twice).

 It is important that this rewrite apply to messages coming from
 outside as well as those originating on my server.
 

virtual_alias_maps apply to all mail.

 - Are all the original and rewritten recipients delivered to another
 host
   via SMTP, or is some of the mail delivered locally (local,
 virtual, ...)?
 
 I'm not completely sure this answers your question, but the message
 may be only to u...@domain1.tld or to a number of addresses including
 u...@domain1.tld. Only the copy of the message to u...@domain1.tld
 should get rerouted to u...@domain2.tld.
 
 both domain1.tld and domain2.tld are mine and my postfix instance is
 the MX for them. domain1.tld is an alias domain and domain2.tld is a
 virtual domain.
 

 My initial guess is to use recipient_canonical_maps and use a pcre
 map:
 /^(.*)@domain1.tld/   {$1)@domain2.tld
 This guess is wrong for many reasons, but I think it best to first
 understand what problem you are really trying to solve, before we
 tear apart the wrong answer to potentially the wrong question.
 
 Thank you...but I would also like to know if I can impose on your
 time, what is wrong with this - it will help me better solve this and
 future problems.
 

see above. wildcard virtual aliases and canonical break recipient
validations.


[snip]




Re: Redirect all mail from one domain to the same u...@otherdomain?

2009-02-09 Thread jeff_homeip
--- In post...@yahoogroups.com, mouss mo...@... wrote:

 jeff_homeip a écrit :
  --- In postfix-us...@yahoogroups.com, Victor Duchovni
  Victor.Duchovni@ wrote:
  On Sun, Feb 08, 2009 at 09:50:16PM -0800, Jeff Weinberger wrote:
 
  I am trying to figure out the best way to map one domain to
  another with
  the same users...precisely the behavior I am trying to achieve is:
  when
  mail is sent (from outside, or from another user within my postfix
  installation) to user@ I want it redirected to user@
  - in otherwords, the user is preserved, but the domain is
  translated/rewritten. To be more specific:
 
  user1@ gets re-routed to user1@
  user2@ gets re-routed to user2@
  - Are you looking to rewrite just the envelope recipient, or also
  message
From/To/Cc headers?
 
  It's only important to rewrite the envelope sender.

 you mean the envelope recipient.

yes, sorry, my typo.

 if so, use virtual_alias_maps. however,
 don't use wildcard virtual aliases. instead, generate one mapping for
 each user:

 us...@... us...@...
 ...


that creates some complications...and might be too difficult

but why not use wildcard virtual aliases? You noted below that they break 
recipient
validations. Do you mean that smtp_recipient_restrictions won't work? at all or 
parts?

Wildcard virtual aliases seems like the best waybut I want to understand 
the implications
on everything esle before I proceed.

Thanks!


 The reason is that if you use
 @example.com  @example.org
 then this breaks recipient validation: smtpd will accept
 anything^example.com, then at delivery time, the user won't be found and
 a bounce will be generated. in short, you become a source of backscatter
 (you send bounces to innocents whose addresses were forged by spammers)

Unless I don't bounce unknown addresses


 you can generate the individual mappings with a script. alternatively,
 if you store users in sql, you can use sql statements to generate these
 on the fly. examples have been posted multiple times to the list (a
 long time ago, that said, but you may be lucky...).



it would be something like:

if (%d='domain1.com') then select %...@domain2..com from virtual_alias else 
select alias
from virtual_alias where address=%s

(that's not quite right in the syntax, but you get the idea). This wont' work, 
as I'd have to
write a special select clause for each domain I want to work this way.


  The result I want
  is that the message is delivered to *...@domain2.tld - if it has the
  original To/Cc header that's fine, and probably desireable.
 

 so you want virtual_alias_maps (yes, these apply to _all_ domains. don't
 confuse with virtual_alias_domains).

  - Is all mail first passed through an SMTP content_filter?
 
  Yes. All mail coming from outside my server is passed through
  amavisd-new for spam/virus checking. Mail originating from my server
  is passed through a specialized content filter. (via the submission
  service)
 

 you must disable rewrite except in one smtpd in a chain. see the FILTER
 README (look for no_address_mappings) or amavisd-new README.postfix.

 if you don't, then virtual aliases will be expanded twice (before and
 after the filter), which may result in duplicate mail (think of a foo
 - foo, bar, which becomes foo - foo, foo, bar if expanded twice).


I already do that..thanks

  It is important that this rewrite apply to messages coming from
  outside as well as those originating on my server.
 

 virtual_alias_maps apply to all mail.

  - Are all the original and rewritten recipients delivered to another
  host
via SMTP, or is some of the mail delivered locally (local,
  virtual, ...)?
 
  I'm not completely sure this answers your question, but the message
  may be only to u...@... or to a number of addresses including
  u...@... Only the copy of the message to u...@...
  should get rerouted to u...@...
 
  both domain1.tld and domain2.tld are mine and my postfix instance is
  the MX for them. domain1.tld is an alias domain and domain2.tld is a
  virtual domain.
 
 
  My initial guess is to use recipient_canonical_maps and use a pcre
  map:
  /^(.*)@domain1.tld/   {$1)@domain2.tld
  This guess is wrong for many reasons, but I think it best to first
  understand what problem you are really trying to solve, before we
  tear apart the wrong answer to potentially the wrong question.
 
  Thank you...but I would also like to know if I can impose on your
  time, what is wrong with this - it will help me better solve this and
  future problems.
 

 see above. wildcard virtual aliases and canonical break recipient
 validations.


 [snip]






Redirect all mail from one domain to the same u...@otherdomain?

2009-02-08 Thread Jeff Weinberger

Hi:

I would appreciate any advice anyone can offer on how best to achieve  
this behavior:


I am trying to figure out the best way to map one domain to another  
with the same users...precisely the behavior I am trying to achieve  
is: when mail is sent (from outside, or from another user within my  
postfix installation) to u...@domain1.tld I want it redirected to u...@domain2.tld 
 - in otherwords, the user is preserved, but the domain is translated/ 
rewritten. To be more specific:


us...@domain1.tld gets re-routed to us...@domain2.tld
us...@domain1.tld gets re-routed to us...@domain2.tld

and so on.

My initial guess is to use recipient_canonical_maps and use a pcre map:

/^(.*)@domain1.tld/   {$1)@domain2.tld

I don't see a way to achieve this with alias_maps and header_checks  
(with action REDIRECT) would miss messages sent to u...@domain1.tld  
where that is not the To: or Cc: address (such as list mail).


Really, I am just checking with experts more knowledgeable than I  
whether I have chosen a good (or the best) way to achieve this, or if  
there is a better way.


Any advice and help are much appreciated!

Thanks,

--Jeff






--

Jeff Weinberger
http://disruptivemarketing.jeffweinberger.com






Re: Redirect all mail from one domain to the same u...@otherdomain?

2009-02-08 Thread Victor Duchovni
On Sun, Feb 08, 2009 at 09:50:16PM -0800, Jeff Weinberger wrote:


 I am trying to figure out the best way to map one domain to another with 
 the same users...precisely the behavior I am trying to achieve is: when 
 mail is sent (from outside, or from another user within my postfix 
 installation) to u...@domain1.tld I want it redirected to u...@domain2.tld 
 - in otherwords, the user is preserved, but the domain is 
 translated/rewritten. To be more specific:

 us...@domain1.tld gets re-routed to us...@domain2.tld
 us...@domain1.tld gets re-routed to us...@domain2.tld

- Are you looking to rewrite just the envelope recipient, or also message
  From/To/Cc headers?

- Is all mail first passed through an SMTP content_filter?

- Are all the original and rewritten recipients delivered to another host
  via SMTP, or is some of the mail delivered locally (local, virtual, ...)?



 My initial guess is to use recipient_canonical_maps and use a pcre map:

 /^(.*)@domain1.tld/   {$1)@domain2.tld

This guess is wrong for many reasons, but I think it best to first
understand what problem you are really trying to solve, before we
tear apart the wrong answer to potentially the wrong question.

 I don't see a way to achieve this with alias_maps and header_checks (with 
 action REDIRECT) would miss messages sent to u...@domain1.tld where that is 
 not the To: or Cc: address (such as list mail).

This is worse.

 Really, I am just checking with experts more knowledgeable than I whether I 
 have chosen a good (or the best) way to achieve this, or if there is a 
 better way.

Yes, there is a correct way of solving your problem, but first describe
your problem in more detail.

-- 
Viktor.

Disclaimer: off-list followups get on-list replies or get ignored.
Please do not ignore the Reply-To header.

To unsubscribe from the postfix-users list, visit
http://www.postfix.org/lists.html or click the link below:
mailto:majord...@postfix.org?body=unsubscribe%20postfix-users

If my response solves your problem, the best way to thank me is to not
send an it worked, thanks follow-up. If you must respond, please put
It worked, thanks in the Subject so I can delete these quickly.