Use this:
if (isin("to","support@n2net.com")) then
call replace("to","*support@n2net.com*","%1support@n2net.net%2")
call replace("to","*support@n2net.com*","%1support@n2net.net%2")
end if
In brief:
1) replace needs 'call' in front of it.
2) don't use recipients, that is a loop for each envelope
recipient, whereas you want to do this for the header which is not
related to the recipients.
3) do it twice, so that it picks up two instances in the single
header.
ChrisP.
On 18/01/2019 3:59 AM, Jim Lohiser wrote:
> SurgeMail List,
>
> We have a need to rewrite an email address in message headers. I am attempting to write an mfilter rule to make this happen. I have created the following rules.
>
> recipients
> if (isin("recipient","support@n2net.com")) then
> replace("to","support@n2net.com","support@n2net.net")
> end if
> end recipients
>
> This works. It replaces both the email address and the "name" portion in the To address (see below).
>
> To: "support@n2net.net" <support@n2net.net>
>
> HOWEVER, if the message has multiple recipients, then the rule does not work.
>
> To: "johndoe@domain1.tld" <johndoe@domain1.tld>, "support@n2net.com" <support@n2net.com>, "janedoe@domain2.tld" <janedoe@domain2.tld>
>
> I know the isin() test is working because I added a "call report()" to the rule block and it sends me a report email. I have tried adding wildcards to the rule (see below), but this also does not work.
>
> replace("to","*support@n2net.com*","%1support@n2net.net%2")
>
> Is there any way to replace all instances of an email address in a header?
>
> Thanks in advance,
>
> Jim Lohiser
> N2Net
>
|