Hi Viktor,

I have changed my configuration with your recommendation, but the Exchange 
server behind the gateway is still receiving mails for us...@example.com 
instead of user1@internal1.example.

Postfix Log:
postfix/smtp[15949]: 08F37AE307: to=<user1@internal.example>, 
orig_to=<us...@example.com>, relay=10.0.0.8[10.0.0.8]:25, delay=0.4, 
delays=0.04/0.02/0.04/0.3, dsn=2.6.0, status=sent (250 2.6.0 
<som...@am5pr0402mb2785.eurprd04.prod.outlook.com> [InternalId=someid] Queued 
mail for delivery)

Exchange Queue:
Last Error: A local loop was detected.
Queue ID: SRV-EXCH01\Submission
Recipients:  us...@example.com;2;0;;0;

On the way outgoing everything looks fine, the "From" Field and "Return-To" are 
rewritten by generic and the mail is delivered fine, only the way incoming 
won't work.

This is exactly the same behavior I experienced with using canonical_maps und 
even with the header_checks... :(

Any idea on what I am doing wrong?

With best regards
Dennis Weber


-----Ursprüngliche Nachricht-----
Von: owner-postfix-us...@postfix.org [mailto:owner-postfix-us...@postfix.org] 
Im Auftrag von Viktor Dukhovni
Gesendet: Sonntag, 23. April 2017 19:19
An: Postfix users <postfix-users@postfix.org>
Betreff: Re: Issues with a Rewriting Gateway


> On Apr 23, 2017, at 7:12 AM, Dennis Weber <dennis.we...@atwork-it.com> wrote:
>  
> I am currently working on a project for a rewriting gateway with postfix, 
> which shall mask two independent internal domains behind a third external DNS 
> name. In general it should accept mails from @internal1.com and 
> @internal2.com as a Smarthost, rewrite the addresses with a new @newcorp.com 
> domain and send it to the public network. Besides the outgoing rewrite it 
> also needs to rewrite incoming mail to both internal domains and transport 
> them to the right Exchange organizations.

See 
https://emea01.safelinks.protection.outlook.com/?url=http%3A%2F%2Fwww.postfix.org%2FSOHO_README.html%23fantasy&data=01%7C01%7Cdennis.weber%40atwork-it.com%7Cbf59aaa1f99e418e717d08d48a6cc76b%7Cd827fc609b284520af06b2d51904fa40%7C1&sdata=fm%2Boo4i%2F8gvK1fD6Ka49ciBk3EzeDQthBTISjT2BD4I%3D&reserved=0

> I managed to rewrite the outgoing messages with the “generic_maps” and 
> a simple filetable

Good, that's the right thing to do outbound, but you should configure the 
"smtp_generic_maps" parameter separately for inbound and inbound mail:

        main.cf:
                indexed = ${default_database_type}:${config_directory}/
                relay_generic_maps =
                smtp_generic_maps = ${indexed}generic
                transport_maps = ${indexed}transport
                virtual_alias_maps = ${indexed}virtual
                virtual_alias_domains = example.com

        master.cf:
                ...
                smtp unix ... smtp
                relay unix ... smtp
                        -o smtp_generic_maps=$relay_generic_maps
                ...

        transport:
                # Inbound mail uses the "relay" transport which
                # avoids the outbound "generic" rewrite.
                # Add optional nexthop gateways as appropriate
                internal1.example       relay
                internal2.example       relay

        virtual:
                # Map external *envelope recipient* addrs to internal
                us...@example.com       user1@internal1.example
                us...@example.com       user2@internal2.example
                ...

        generic:
                # Map internal addrs to external in envelope and headers
                user1@internal1.example us...@example.com
                user2@internal2.example us...@example.com       
        
>       • Messages rewritten with “header_checks” cannot be delivered too, 
> because of the same reason mentioned above

NEVER EVER ATTEMPT OR EVEN THINK ABOUT using header checks for address 
rewriting.

-- 
        Viktor.

Reply via email to