POSTFIX relay

    Заставляем postfix пересылать почту через внешний сервер.

    /etc/postfix/main.cf
    #--- Send Mail via External Relay ----
    relayhost = [smtp.yandex.ru]:587
    smtp_sasl_auth_enable = yes
    smtp_sasl_password_maps = hash:/etc/postfix/sasl_passwd
    smtp_sasl_security_options = noanonymous
    smtp_tls_CAfile = /etc/postfix/cacert.pem
    smtp_use_tls = yes
    smtp_tls_security_level = may
    smtp_sasl_tls_security_options = noanonymous
    #--  Sender rules ---
    sender_canonical_classes = envelope_sender, header_sender
    sender_canonical_maps =  regexp:/etc/postfix/sender_canonical_maps
    smtp_header_checks = regexp:/etc/postfix/header_check

    Данные для авторизации почтового ящика:

    /etc/postfix/sasl_passwd
    [smtp.yandex.ru]:587 new_sender@address.com:mypassword

    Заменяем любого отправителя новым адресом:

    /etc/postfix/sender_canonical_maps
    /.+/    new_sender@address.com
    

    Так же подменяем отправителя в заголовке From новым адресом:

    /etc/postfix/header_check:
    /From:.*/ REPLACE From: new_sender@address.com

    Copyright © 2022Powered by Bludit