Re: Convert _ to + on inbound addresses

2010-01-18 Thread Charles Boling
 with SQL, there is no need to use pcre. just do that in the SQL query to
 avoid having to keep an external file up to date...

...except that the + (and everything between it and the @) is *not*
actually part of the email address.  To use your address as an example:

When Postfix receives an envelope for:
mouss+nob...@netoyen.net
It automatically strips the +nobulk and what it actually looks up in
the database is:
mo...@netoyen.net


I assume that the + magic is hard-coded in Postfix, so if I [knew what
I was doing, and] were to dig out the source code, it would be pretty
simple to change it to use _ instead of +.  If I were to upgrade
this hack to something more respectable, I would:
   1. Create a configurable parameter, rather than hard-coding it
   2. Allow multiple characters (so I could still use + as well)



Re: Convert _ to + on inbound addresses

2010-01-18 Thread /dev/rob0
On Mon, Jan 18, 2010 at 09:12:00AM -0800, Charles Boling wrote:
mouss:
  with SQL, there is no need to use pcre. just do that in the SQL 
  query to avoid having to keep an external file up to date...
 
 ...except that the + (and everything between it and the @) is 
 *not* actually part of the email address.

Yes it is. The entire address including + is always looked up
first, in any map type.

  To use your address as an example:
 
 When Postfix receives an envelope for:
   mouss+nob...@netoyen.net
 It automatically strips the +nobulk and what it actually looks up 
 in the database is:
   mo...@netoyen.net

If the lookup of the entire address fails, the recipient_delimiter
and all characters which follow, up to the @, are stripped, and the
second lookup is done.

 I assume that the + magic is hard-coded in Postfix, so if I [knew 
 what I was doing, and] were to dig out the source code, it would be 
 pretty simple to change it to use _ instead of +.  If I were to 
 upgrade this hack to something more respectable, I would:
1. Create a configurable parameter, rather than hard-coding it

postconf.5.html#recipient_delimiter -- you're a few years too late.

2. Allow multiple characters (so I could still use + as well)

This is non-trivial and has been recently addressed by Wietse. Be
content with the workarounds you have been offered.
-- 
Offlist mail to this address is discarded unless
/dev/rob0 or not-spam is in Subject: header


Re: Convert _ to + on inbound addresses

2010-01-18 Thread mouss
Charles Boling a écrit :
 with SQL, there is no need to use pcre. just do that in the SQL query to
 avoid having to keep an external file up to date...
 
 ...except that the + (and everything between it and the @) is *not*
 actually part of the email address. 

of course the + is part of the email address. you may want to reread
my post.

 To use your address as an example:
 
 When Postfix receives an envelope for:
   mouss+nob...@netoyen.net
 It automatically strips the +nobulk and what it actually looks up in
 the database is:
   mo...@netoyen.net
 

you want to read the docs about recipient_delimiter.

PS. mail to mouss-...@netoyen.net and mouss+...@netoyen.net will get to
the same mailbox. both '-' and '+' are supported here, for now. but '-'
is encouraged because '+' is not well accepted, as you noticed. so at
some time, '+' support may be removed.

 
 I assume that the + magic is hard-coded in Postfix, so if I [knew what
 I was doing, and] were to dig out the source code, it would be pretty
 simple to change it to use _ instead of +.  If I were to upgrade
 this hack to something more respectable, I would:
1. Create a configurable parameter, rather than hard-coding it

that's recipient_delimiter...

2. Allow multiple characters (so I could still use + as well)
 

postfix doesn't support multiple chars in recipient_delimiter. to
understand why, try to read the docs about what lookups postfix does
when it sees foo+...@example.com
it will check:
foo+...@example.com
f...@example.com
example.com (or @example.com ... depending on context)
That's 3 queries. now, if you want two delimiters, say '+' and '-' then
how many queries would
foo+bar-...@example.com
result in?
foo+bar-...@example.com
foo+...@example.com
f...@example.com
...
as you can see, each additional delimiter adds one query...





Re: Convert _ to + on inbound addresses

2010-01-17 Thread mouss
LuKreme a écrit :
 On 16-Jan-2010, at 12:24, Wietse Venema wrote:
 To address that issue, I would like to be able to use another character
 (_ or .) that is commonly accepted as part of email addresses, instead.
 Address transformation mappings are always queried at recipient
 validation time, so you can't use a wild-card pattern to replace
 _ by + without becoming a backscatter source.
 
 
 This has been covered on the list in the past (I know, I was the supplicant 
 last time).
 
 I have a fairly static user list, so I managed it this way:
 
 For local users, I have a virtual.pcre file that contains lines like:
 
 /^kremels_(.*)@kreme.com$/kremels+${1}
 
 for the non-local (SQL users) I have another file, virtual_sql.pcre with very 
 similar lines like:
 
 /^info_(.*)@domain\.tld$/ info+$...@domain\.tld
 
 and in main.cf I have:
 
 virtual_alias_maps = 
 hash:$config_directory/virtual
 pcre:$config_directory/virtual.pcre,
 pcre:$config_directory/virtual_sql.pcre,
 proxy:mysql:$config_directory/mysql_virtual_alias_maps.cf
 
 If your user list changes frequently, then this is not a really workable 
 solution unless you can automate the creation of the pcre files.
 

with SQL, there is no need to use pcre. just do that in the SQL query to
avoid having to keep an external file up to date...

mysql set @s:=foo_bar_...@example.com;
Query OK, 0 rows affected (0.00 sec)
mysql select concat(substring(@s, 1, locate(_, @s)-1), +,
substring(@s, locate(_, @s)+1)) ;
++
| concat(substring(@s, 1, locate(_, @s)-1), +, substring(@s,
locate(_, @s)+1)) |
++
| foo+bar_...@example.com
 |
++
1 row in set (0.00 sec)



Re: Convert _ to + on inbound addresses

2010-01-16 Thread Brian Mathis
On Sat, Jan 16, 2010 at 11:06 AM, Charles Boling
junk01+post...@boling.us wrote:
 I've been a postfix user for nearly 10 years, but in many ways I'm still
 quite the newbie.  That's the problem with Postfix being such a solid
 MTA: I don't mess with it much. :-)

 For a good chunk of that time, I have wrestled on and off with this
 problem off and on, playing with it for a bit, giving up, then returning
 to it a year or two later.  After all this time, I've finally gotten
 smart enough to specifically ask for help!

 I love + addressing, the ability to append ad-hoc suffixes to an email
 address (like the one used to post to this list).  The problem is, a lot
 of web sites don't.  They tend to take the lazy route to preventing SQL
 injection attacks, and reject any address with a + in it.

 To address that issue, I would like to be able to use another character
 (_ or .) that is commonly accepted as part of email addresses, instead.

 When an email comes into Postfix (v2.2 currently), I would like it to
 search for, e.g. _ in the recipient address, and replace it with +.
  This, of course, needs to happen before it does recipient checking.
 The validated message is eventually passed on to the MDA (Cyrus, in my
 case) with the + in it.

 How might be the best way to accomplish this?


You might want to look at the recipient_delimiter configuration
directive, which you can use to change the delimiter.  It doesn't
search and replace like what you are specifically looking for, but it
might solve your problem.


Re: Convert _ to + on inbound addresses

2010-01-16 Thread Wietse Venema
Charles Boling:
 I've been a postfix user for nearly 10 years, but in many ways I'm still
 quite the newbie.  That's the problem with Postfix being such a solid
 MTA: I don't mess with it much. :-)
 
 For a good chunk of that time, I have wrestled on and off with this
 problem off and on, playing with it for a bit, giving up, then returning
 to it a year or two later.  After all this time, I've finally gotten
 smart enough to specifically ask for help!
 
 I love + addressing, the ability to append ad-hoc suffixes to an email
 address (like the one used to post to this list).  The problem is, a lot
 of web sites don't.  They tend to take the lazy route to preventing SQL
 injection attacks, and reject any address with a + in it.
 
 To address that issue, I would like to be able to use another character
 (_ or .) that is commonly accepted as part of email addresses, instead.

Address transformation mappings are always queried at recipient
validation time, so you can't use a wild-card pattern to replace
_ by + without becoming a backscatter source.

The only way to change an envelope address before SMTP server
recipient validation is with the Postfix 2.7 smtpd_command_filter
which replaces SMTP commands before they are executed.  This is
for the desperate. It has no safety mechanisms.

http://www.postfix.org/postconf.5.html#smtpd_command_filter

Wietse

 When an email comes into Postfix (v2.2 currently), I would like it to
 search for, e.g. _ in the recipient address, and replace it with +.
  This, of course, needs to happen before it does recipient checking.
 The validated message is eventually passed on to the MDA (Cyrus, in my
 case) with the + in it.
 
 How might be the best way to accomplish this?
 
 
 



Re: Convert _ to + on inbound addresses

2010-01-16 Thread LuKreme
On 16-Jan-2010, at 12:24, Wietse Venema wrote:
 To address that issue, I would like to be able to use another character
 (_ or .) that is commonly accepted as part of email addresses, instead.
 
 Address transformation mappings are always queried at recipient
 validation time, so you can't use a wild-card pattern to replace
 _ by + without becoming a backscatter source.


This has been covered on the list in the past (I know, I was the supplicant 
last time).

I have a fairly static user list, so I managed it this way:

For local users, I have a virtual.pcre file that contains lines like:

/^kremels_(.*)@kreme.com$/kremels+${1}

for the non-local (SQL users) I have another file, virtual_sql.pcre with very 
similar lines like:

/^info_(.*)@domain\.tld$/ info+$...@domain\.tld

and in main.cf I have:

virtual_alias_maps = 
hash:$config_directory/virtual
pcre:$config_directory/virtual.pcre,
pcre:$config_directory/virtual_sql.pcre,
proxy:mysql:$config_directory/mysql_virtual_alias_maps.cf

If your user list changes frequently, then this is not a really workable 
solution unless you can automate the creation of the pcre files.

-- 
I WILL NOT CUT CORNERS
   
Bart chalkboard Ep. 7F11