On Thu, Aug 15, 2024 at 05:15:01PM -0400, Wietse Venema via Postfix-users wrote:
> Etienne Gladu via Postfix-users:
> > In short, I want postfix to change the recipient of all email going through 
> > port 7025, 7026, etc
> > In exemple : email came from port 7025, then redirect/change recipient to 
> > d...@test.ca
> > if its 7026, redirect/change recipient to a...@test.ca
> 
> The client (and server port) are available in the SMTP policy
> delegation protocol. 
> 
> If you were to use the Perl code in the SMTPD_POLICY_RADME.html it
> might look like:
> 
>     if ($attr{'client_port'} == 7025) { print("action=redirect 
> d...@test.ca\n\n"); }

The OP is probably interested in the 'server_port' rather than
the 'client_port'.  Relevant policy request attributes include:

    Postfix version 3.1 and later:
    policy_context (see 
https://www.postfix.org/postconf.5.html#smtpd_policy_service_policy_context)

    Postfix version 3.2 and later:
    server_address  (Postfix SMTP service IP (v4 or v6) address)
    server_port     (Postfix SMTP service TCP port)

> But it may also be possible with postfwd, or with policy plugins in other 
> languages.
> 
> > Maybe it's just not possible with postfix?
> 
> It is possible.

One can also override the restriction classes for each SMTP listener in
master.cf(5):

    7025    inet ... smtpd
        -o { smtpd_command_filter = pcre:{ {/^(MAIL FROM):/ 
$1:<nepasrepon...@test.ca> } }
        -o { smtpd_client_restrictions = check_client_access static:{REDIRECT 
d...@test.ca} }
        -o { smtpd_relay_restrictions = permit_mynetworks, reject }
        -o { smtpd_helo_restrictions = }
        -o { smtpd_sender_restrictions = }
        -o { smtpd_recipient_restrictions = }
        -o { smtpd_data_restrictions = }
        -o { smtpd_end_of_data_restrictions = }
    7026    inet ... smtpd
        -o { smtpd_command_filter = pcre:{ {/^(MAIL FROM):/ 
$1:<nepasrepon...@test.ca> } }
        -o { smtpd_client_restrictions = check_client_access static:{REDIRECT 
a...@test.ca} }
        -o { smtpd_relay_restrictions = permit_mynetworks, reject }
        -o { smtpd_helo_restrictions = }
        -o { smtpd_sender_restrictions = }
        -o { smtpd_recipient_restrictions = }
        -o { smtpd_data_restrictions = }
        -o { smtpd_end_of_data_restrictions = }

-- 
    Viktor.
_______________________________________________
Postfix-users mailing list -- postfix-users@postfix.org
To unsubscribe send an email to postfix-users-le...@postfix.org

Reply via email to