cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
1100
Views
20
Helpful
2
Replies

Can I rewrite the recipient address with a message filter with regex

CCH
Level 1
Level 1

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!

2 Replies 2

Udupi Krishna.
Cisco Employee
Cisco Employee

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.

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:

  • $envelopefrom
  • $envelopesender" (not other variables are alowed)

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.