Re: [exim] need to rewrite _ characters in MAIL FROM domain …

Top Page
Delete this message
Reply to this message
Author: Todd Lyons
Date:  
To: Dave Lugo
CC: exim-users
Subject: Re: [exim] need to rewrite _ characters in MAIL FROM domain part
On Tue, Nov 22, 2011 at 6:35 AM, Dave Lugo <dlugo@???> wrote:
>> I seem to have some apps that are sending with a underscore in
>> the domain part.  Searching the exim-user archives suggests that
>> I can work around this by rewriting the MAIL FROM address,
>> replacing the domain part _ chars with . chars.
> I decided to try to be simple - any MAIL FROM with a domain part
> ending in example.com, that is preceeded by an element containing
> an underscore, gets replaced with example.com.


That's not what your regex has below. Let's analyze it.

> user@???_asd_asd.example.com  --->  user@???
> But trying to go with this:
> \N^(.*)@*_*.example.com(.*)$\N    $1@???$4        SF


Wrapping the regex with \N is good. That means you don't have to do
do all kinds of ugly escaping.

What is messing you up is the @*_*. That literally means "zero or
more @ signs followed by zero or more _ signs". What you meant was
"@.*_.*\.example.com". You were thinking shell style or sendmail
style wildcard instead of regex.

Second, you said "with a domain part ending in example.com". But your
regex searches for "example.com(.*). That means that example.com
could match anywhere in the hostname.

Finally, drop the $4 from the rewrite part.

CentOS56[root@ivwm51 ~]# grep example.com /etc/exim/exim_TEST.conf
\N^(.*)@.*_.*.example.com.*$\N    $1@???        SF
CentOS56[root@ivwm51 ~]# exim -C /etc/exim/exim_TEST.conf -brw
user@???_asd_asd.example.com
    SMTP: user@???


Regards....          Todd
-- 
If Americans could eliminate sugary beverages, potatoes, white bread,
pasta, white rice and sugary snacks, we would wipe out almost all the
problems we have with weight and diabetes and other metabolic
diseases. -- Dr. Walter Willett, Harvard School of Public Health