Thanks very much for your reply, my followup below...
On Tue, 22 Nov 2011, Todd Lyons wrote:
On Tue, Nov 22, 2011 at 6:35 AM, Dave Lugo <[email protected]> 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.
[email protected]_asd_asd.example.com ---> [email protected]
But trying to go with this:
\N^(.*)@*_*.example.com(.*)$\N [email protected]$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 [email protected] SF
CentOS56[root@ivwm51 ~]# exim -C /etc/exim/exim_TEST.conf -brw
[email protected]_asd_asd.example.com
SMTP: [email protected]
that works great for -brw, but when wrapped in <>, it fails:
mail from:<user@a_sd.asd_asdasd.example.com>
LOG: Rewrite of <user@a_sd.asd_asdasd.example.com> yielded unparseable
address: '>' missing at end of address in address <[email protected]
LOG: SMTP syntax error in "mail from:<user@a_sd.asd_asdasd.example.com>"
H=localhost (ad) [127.0.0.1] malformed address:
_sd.asd_asdasd.example.com> may not follow <user@a
501 <user@a_sd.asd_asdasd.example.com>: malformed address:
_sd.asd_asdasd.example.com> may not follow <user@a
I can't unfortunately guarantee that clients will do the right
thing, or not, with regards to < > usage.
Can both cases be done in the same rewrite rule? Should I use
two rewrite rules instead?
Thanks,
Dave
--
--------------------------------------------------------
Dave Lugo [email protected] No spam, thanks.
Are you the police? . . . No ma'am, we're sysadmins.
--------------------------------------------------------
--
## List details at https://lists.exim.org/mailman/listinfo/exim-users
## Exim details at http://www.exim.org/
## Please use the Wiki with this list - http://wiki.exim.org/