On 10/22/2013 8:41 AM, btb wrote:
> On 2013.10.21 17.54, Noel Jones wrote:
>> On 10/21/2013 3:53 PM, btb wrote:
>>> i have a scenario in which certain email is sent using envelope
>>> senders that contain host names that are known only on the local
>>> lan/network, and unknown on the internet.  most mail expressing that
>>> characteristic stays local, but occasionally, some is legitimately
>>> destined for the public internet.  to that end, with such mail, i'd
>>> like to change the sender domain part to @example.com, but only if
>>> the recipient domain part does not end in example.com [both the
>>> sender and recipient domain part may be @example.com,
>>> @foo.example.com, @bar.foo.example.com, etc].
>>>
>>> what is the right method for doing this?  given
>>> ADDRESS_REWRITING_README, it seem to possibly be a fit for either
>>> masquerade_domains or smtp_generic_maps, but i'm not certain, and
>>> i'm not sure how to apply selectively.
>>>
>>> -ben
>>
>> smtp_generic_maps will do that nicely. Add the rewriting on the
>> "smtp" outgoing transport in master.cf to limit rewriting to
>> non-local recipient domains only.
>>
>> #master.cf
>> # find the existing "smtp unix ... smtp" transport and add to it:
>>    -o smtp_generic_maps=regexp:/etc/postfix/generic.regexp
>>
>>
>> # generic.regexp
>> /^(.*)@some\.fantasy\.invalid$/  $1...@example.com
> 
> thanks.  wrt limit rewriting to non-local recipient domains only, by "stays 
> local", i meant local in terms of the local network, not in terms of postfix. 
>  postfix is responsible for only systems.example.com:
> 
> virtual_mailbox_domains = ldap:$table_directory/virtual_mailbox_domains.cf
> 
>> postmap -q 'systems.example.com' ldap:./tables/virtual_mailbox_domains.cf 
> systems.example.com
> 
> while everything else leaves via smtp and is delivered via mx records - some 
> of which is for other recipients ending in @example.com or .example.com 
> [delivered to other hosts on the local network], and the rest of course out 
> onto the internet.  how can i apply smtp_generic_maps selectively, for only 
> certain recipient domains [ones not ending in @example.com or .example.com] 
> leaving via smtp - the goal being to rewrite the sender to @example.com for 
> mail destined for the internet?
> 
> -ben
> 

Postfix doesn't have a specific feature to rewrite the sender based
on the recipient.

Arrange for internal network traffic to use a specific transport,
such as the "relay" transport, and let internet traffic use the
default "smtp" transport.

# transport
.example.com  relay:


  -- Noel Jones

Reply via email to