Postfix : réécriture des entêtes mail

Boris HUISGEN
Boris HUISGEN
|

Je présente ici deux méthodes permettant de réécrire les entêtes d’un message électronique.

root@srv# apt-get install postfix-pcre

Avant filtrage externe

root@srv# vim /etc/postfix/main.cf

header_checks = pcre:/etc/postfix/header_checks.cf

root@srv# cat /etc/postfix/header_checks.cf

/^Subject:/ WARN
/^Subject: .*(@domain1|@domain2)\.(com|fr)/ DISCARD

Après filtrage externe

root@srv# vim /etc/postfix/master.cf

127.0.0.1:10025 inet n  -       n       -       -       smtpd
    -o content_filter=
    -o local_recipient_maps=
    -o relay_recipient_maps=
    -o smtpd_restriction_classes=
    -o smtpd_client_restrictions=
    -o smtpd_helo_restrictions=
    -o smtpd_sender_restrictions=
    -o smtpd_recipient_restrictions=permit_mynetworks,reject
    -o smtpd_data_restrictions=reject_unauth_pipelining
    -o smtpd_end_of_data_restrictions=
    -o mynetworks=127.0.0.0/8
    -o strict_rfc821_envelopes=yes
    -o smtpd_error_sleep_time=0
    -o smtpd_soft_error_limit=1001
    -o smtpd_hard_error_limit=1000
    -o smtpd_client_connection_count_limit=0
    -o smtpd_client_connection_rate_limit=0
    -o receive_override_options=no_address_mappings,no_unknown_recipient_checks,no_milters
    -o cleanup_service_name=smtp-cleanup
    -o local_header_rewrite_clients=

smtp-cleanup   unix  n  -       n       -       0       cleanup
    -o header_checks=pcre:/etc/postfix/header_cleanup.cf

root@srv:# cat /etc/postfix/header_cleanup.cf

/^Received: from localhost \(localhost \[127\.0\.0\.1\]\)/ IGNORE
/^Received: (.*) \(Postfix\) (.*)/ REPLACE Received: ${1} ${2}
/^X-Originating-IP:/ IGNORE
Boris HUISGEN
Boris HUISGEN
Blog owner
  • #postfix