From: Patric Falinder on
> (copy of an answer from a few days ago)
>
> To deliver to two destinations, you need two recipients.
>
> You can use a regexp recipient_bcc_maps to add another
> recipient, then use smtp_generic_maps to rewrite it back to
> the original during delivery. Use a transport_maps entry to
> direct the bcc'ed mail to the proper server.
>
> # main.cf
> recipient_bcc_maps = regexp:/etc/postfix/recipient_bcc
> smtp_generic_maps = hash:/etc/postfix/smtp_generic
> transport_maps = hash:/etc/postfix/transport
>
> # recipient_bcc
> if /@example\.com/
> /^.*@example\.com$/ $1(a)new.example.com
> endif
>
> # smtp_generic
> @new.example.com @example.com
>
> # transport
> new.example.com smtp:new.server.example.com
>
> Be sure to postmap the hash: tables after making changes to them.
>
> -- Noel Jones

If I have a subdomain that I need to do this with, sub.domain.com,
should it he like this then?

/etc/postfix/recipient_bcc:
if /@sub\.domain\.com/
/^.*@sub\.domain\.com$/ $1(a)new.domain.com
endif

I get this error:
warning: regexp map /etc/postfix/recipient_bcc, line 2: out of range
replacement index "1": skipping this rule

What did I do wrong?

From: Ansgar Wiechers on
On 2010-03-24 Patric Falinder wrote:
> If I have a subdomain that I need to do this with, sub.domain.com,
> should it he like this then?
>
> /etc/postfix/recipient_bcc:
> if /@sub\.domain\.com/
> /^.*@sub\.domain\.com$/ $1(a)new.domain.com
> endif

You can probably omit the "if ... endif", the match alone should be
sufficient.

> I get this error:
> warning: regexp map /etc/postfix/recipient_bcc, line 2: out of range
> replacement index "1": skipping this rule
>
> What did I do wrong?

You didn't group what the $1 is supposed to refer to.

/^(.*)@sub\.domain\.com$/ $1(a)new.domain.com

Regards
Ansgar Wiechers
--
"Abstractions save us time working, but they don't save us time learning."
--Joel Spolsky

From: Patric Falinder on
Ansgar Wiechers skrev 2010-03-24 11:49:
> On 2010-03-24 Patric Falinder wrote:
>> If I have a subdomain that I need to do this with, sub.domain.com,
>> should it he like this then?
>>
>> /etc/postfix/recipient_bcc:
>> if /@sub\.domain\.com/
>> /^.*@sub\.domain\.com$/ $1(a)new.domain.com
>> endif
>
> You can probably omit the "if ... endif", the match alone should be
> sufficient.
>
>> I get this error:
>> warning: regexp map /etc/postfix/recipient_bcc, line 2: out of range
>> replacement index "1": skipping this rule
>>
>> What did I do wrong?
>
> You didn't group what the $1 is supposed to refer to.
>
> /^(.*)@sub\.domain\.com$/ $1(a)new.domain.com
>
> Regards
> Ansgar Wiechers

ah, I changed that but now I get this error message:

warning: regexp map /etc/postfix/recipient_bcc, line 1: using empty
replacement string
warning: recipient_bcc_maps lookup of patric.falinder(a)sub.domain.com
returns an empty string result
warning: recipient_bcc_maps should return NO RESULT in case of NOT FOUND

Should there be something more on the first line?
I'm a total noob when it comes to scripting and such.

I have all my users and stuff in a MySQL-databse if that would be some
kind of problem here I don't know!?

Thanks,
Patric

From: Patric Falinder on
Patric Falinder skrev 2010-03-24 12:00:
> Ansgar Wiechers skrev 2010-03-24 11:49:
>> On 2010-03-24 Patric Falinder wrote:
>>> If I have a subdomain that I need to do this with, sub.domain.com,
>>> should it he like this then?
>>>
>>> /etc/postfix/recipient_bcc:
>>> if /@sub\.domain\.com/
>>> /^.*@sub\.domain\.com$/ $1(a)new.domain.com
>>> endif
>>
>> You can probably omit the "if ... endif", the match alone should be
>> sufficient.
>>
>>> I get this error:
>>> warning: regexp map /etc/postfix/recipient_bcc, line 2: out of range
>>> replacement index "1": skipping this rule
>>>
>>> What did I do wrong?
>>
>> You didn't group what the $1 is supposed to refer to.
>>
>> /^(.*)@sub\.domain\.com$/ $1(a)new.domain.com
>>
>> Regards
>> Ansgar Wiechers
>
> ah, I changed that but now I get this error message:
>
> warning: regexp map /etc/postfix/recipient_bcc, line 1: using empty
> replacement string
> warning: recipient_bcc_maps lookup of patric.falinder(a)sub.domain.com
> returns an empty string result
> warning: recipient_bcc_maps should return NO RESULT in case of NOT FOUND
>
> Should there be something more on the first line?
> I'm a total noob when it comes to scripting and such.
>
> I have all my users and stuff in a MySQL-databse if that would be some
> kind of problem here I don't know!?
>
> Thanks,
> Patric
Is there no one that can help me with this? I really need this, or
something similar, to work. Is it perhaps possible to do it with some
other function?

Thanks,
Patric

From: Wietse Venema on
Patric Falinder:
> > ah, I changed that but now I get this error message:
> >
> > warning: regexp map /etc/postfix/recipient_bcc, line 1: using empty
> > replacement string
> > warning: recipient_bcc_maps lookup of patric.falinder(a)sub.domain.com
> > returns an empty string result
> > warning: recipient_bcc_maps should return NO RESULT in case of NOT FOUND
> >
> > Should there be something more on the first line?
> > I'm a total noob when it comes to scripting and such.
> >
> > I have all my users and stuff in a MySQL-databse if that would be some
> > kind of problem here I don't know!?
> >
> > Thanks,
> > Patric
> Is there no one that can help me with this? I really need this, or
> something similar, to work. Is it perhaps possible to do it with some
> other function?

You show the error message BUT you did not show the configuration.

Wietse