03-09-2022 08:33 AM
Hello,
I would like to rewrite recipient of incoming messages with specific adresses with a regex, and currently i'm not able to make it work properly with regexp:
For example if an incoming mail matches "exampleppl_admin@domain.com" as recipient, i want to deliver it to "exampleppl@domain.com"
I tried via content filter: it's easy to edit the "to" header (with match for the '_admin' and replacing by nothing) but it's not working for the "rcpt-to" header: have anybody already done such thing?
Alias table could be another solution but, as we have turnover of our people, i would prefer not to have to update anything.
Thx in advance for any help provided!
03-10-2022 07:14 PM - edited 03-10-2022 07:14 PM
The easiest way I know of is to setup a content filter with "change recipient to" action or use message filter with "alter recipient action".
Here's a working example,
Fri Mar 11 02:33:39 2022 Info: MID 802 ICID 933 From: <alex.mercer@gmail.com>
Fri Mar 11 02:33:39 2022 Info: MID 802 ICID 933 RID 0 To: <exampleppl_admin@domain.com>
Fri Mar 11 02:33:39 2022 Info: MID 802 SPF: helo identity postmaster@[X.X.X.X] None
Fri Mar 11 02:33:40 2022 Info: MID 802 SPF: mailfrom identity alex.mercer@gmail.com SoftFail (v=spf1)
Fri Mar 11 02:33:40 2022 Info: MID 802 DMARC: Message from domain gmail.com, DMARC fail, (SPF aligned False, DKIM aligned False) DMARC policy is none, applied policy is none
Fri Mar 11 02:33:40 2022 Info: MID 802 DMARC: Verification failed.
Fri Mar 11 02:33:40 2022 Info: MID 802 DMARC: No action taken by DMARC policy.
Fri Mar 11 02:33:40 2022 Info: MID 802 Message-ID '<9922e395-6803-3f45-d1f1-38c080965c05@gmail.com>'
Fri Mar 11 02:33:40 2022 Info: MID 802 Subject Testing re-write
Fri Mar 11 02:33:44 2022 Info: MID 802 rewritten to MID 803 by alt-rcpt-to-filter filter 'testrewritercpt'
Fri Mar 11 02:33:44 2022 Info: MID 803 ICID 0 From: <alex.mercer@gmail.com>
Fri Mar 11 02:33:44 2022 Info: MID 803 ICID 0 RID 0 To: <exampleppl@domain.com>
Fri Mar 11 02:33:44 2022 Info: Message finished MID 802 done
But scaling this to multiple users/email addresses may be challenging unless a regex can cover different scenarios.
03-11-2022 12:21 AM
Hello,
Thanks for your answer. Unfortunately the alt-rcpt seems not to allow variables (previously splited for example) or regex:
"The address must be an email address or one of variables:
So if i use this solution, i'll have to write an action for each recipient, and as we have turnover i would prefer a solution that removes the "_admin" of any mail matching the mail policy.
Best regards,
CCH.
Discover and save your favorite ideas. Come back to expert answers, step-by-step guides, recent topics, and more.
New here? Get started with these tips. How to use Community New member guide