Substitute original address in virtual_alias_maps

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Substitute original address in virtual_alias_maps

MegaBrutal
Hello,

If I have a virtual alias map like this:

@domain.tld        [hidden email] [hidden email]

Then all e-mails to domain.tld will be forwarded to the two given
addresses, right?

Fine. But then, I want those e-mails to be delivered to the original
recipient too. For example, if [hidden email] receives an e-mail, I
want it to be delivered to 3 addresses: [hidden email],
[hidden email], and [hidden email] itself. If I could
add the address to the list, it would be fine, but... it's a variable.
How can I substitute a variable there? Something like:

@domain.tld        [hidden email]
[hidden email] $originaladdress

But I don't know what can I supply to substitute the original address with.

I hope you understand my goal, as I didn't have much time to compose clearly.


Best regards,
MegaBrutal
Reply | Threaded
Open this post in threaded view
|

Re: Substitute original address in virtual_alias_maps

Wietse Venema
MegaBrutal:

> Hello,
>
> If I have a virtual alias map like this:
>
> @domain.tld        [hidden email] [hidden email]
>
> Then all e-mails to domain.tld will be forwarded to the two given
> addresses, right?
>
> Fine. But then, I want those e-mails to be delivered to the original
> recipient too. For example, if [hidden email] receives an e-mail, I
> want it to be delivered to 3 addresses: [hidden email],
> [hidden email], and [hidden email] itself. If I could
> add the address to the list, it would be fine, but... it's a variable.
> How can I substitute a variable there? Something like:
>
> @domain.tld        [hidden email]
> [hidden email] $originaladdress
>
> But I don't know what can I supply to substitute the original address with.

Use a PCRE table, capture the original address with (), and
place it in the expansion as $1:

/etc/postfix/virtual.pcre:
    /(.+@example\.com$) $1, addr, addr

/etc/postfix/main.cf:
    virtual_alias_maps = pcre:/etc/postfix/virtual.pcre, othermaps...

In the left-hand pattern, the '\' and '$' are required to avoid
false matches.

        Wietse