Viktor Dukhovni:
> On Tue, Jul 06, 2021 at 12:56:50PM +0200, Xavier Beaudouin wrote:
> 
> > I currently have an appliance that misuse the null sender (mail
> > from:<>) to send mail.
> >
> > Unfortunatly, this appliance is closed source
> > and we can only setup : fixed ip address and recipient address on GUI
> > (nothing else, even if I try to h4x0r the configuration file).
> >
> > Is there any good advice I can have to make the internal relay server
> > which is postfix based to rewrite the null sender to something
> > cleaner... but ONLY for the device that use postfix as internal relay
> > server?
> 
> This requires a content filter or milter, that replaces the envelope
> sender address for messages from the client IP address in question.
> 
> There is no built-in feature that performs sender address rewrites
> conditional on the client IP address.
> 
> The milter should be easy to implement.

There is another option:

1 - Configure a Postfix smtpd process on an additional IP addresss
    or TCP port that only this client will connect to.

2 - Configure that smtpd process with an smtpd_command_filter that
    replaces "MAIL FROM:<>" with the preferred address.

    # Listen on port 1234
    /etc/postfix/master.cf:
        1234   inet ..   ..   ..   ..   ..   smtpd
            -o {smtpd_command_filter = pcre:/etc/postfix/command_filter}

    # Listen on IP address 1.2.3.4
    /etc/postfix/master.cf:
        1.2.3.4:smtp   inet ..   ..   ..   ..   ..   smtpd
            -o {smtpd_command_filter = pcre:/etc/postfix/command_filter}

    /etc/postfix/command_filter:
       /^(MAIL FROM:)\s*<>/     MAIL FROM:<u...@example.com>

        Wietse

Reply via email to