萬盛學電腦網

您现在的位置: 萬盛學電腦網 >> 程式設計 >  >> 伺服器教學

Postfix 串接多個 Content Filter(Amavisd + Avira MailGate)實戰配置

場景

已有 Postfix + Amavisd,需再加入無法整合至 Amavisd 的 Avira MailGate,採用「串接過濾器」架構:

Postfix(25) → MailGate(20024) → Postfix(20025) → Amavisd(10026) → Postfix(10027) → User

各組件監聽埠

服務接收埠轉發埠
Amavisd1002610027
MailGate2002420025

Postfix 配置

main.cf

content_filter = smtp:127.0.0.1:20024

master.cf

# 1. MailGate 掃描後回郵至此埠
localhost:20025 inet n - n - - smtpd
    -o content_filter=smtp:127.0.0.1:10026

# 2. Amavisd 掃描後回郵至此埠,直接遞送給用戶
127.0.0.1:10027 inet n - n - - smtpd
    -o content_filter=
    -o smtpd_delay_reject=no
    -o smtpd_client_restrictions=permit_mynetworks,reject
    -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 smtpd_restriction_classes=
    -o mynetworks=127.0.0.0/8
    -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_header_body_checks,no_unknown_recipient_checks,no_milters
    -o local_header_rewrite_clients=

另一種鏈式寫法(Amavisd → Altermime)

main.cf:
content_filter = amavisd:[127.0.0.1]:10024

master.cf:
amavisd unix - - n - 2 lmtp
    -o lmtp_data_done_timeout=1200s
    -o disable_dns_lookups=yes

127.0.0.1:10025 inet n - n - - smtpd
    -o content_filter=altermine

altermine unix - - n - 2 pipe
    ...

127.0.0.1:20025 inet n - n - - smtpd
    -o content_filter=
    -o ...

流向:postfix → amavisd → postfix → altermine → postfix → user

關鍵點

  • 每個「回郵」埠都啟動一個獨立的 smtpd 實例,並透過 -o content_filter= 指定下一級過濾器或關閉過濾。
  • mynetworks=127.0.0.0/8 確保內部轉發不被拒收。
  • 調整 smtpd_*_error_limit 避免大量郵件導致暫時拒收。
copyright © 萬盛學電腦網 all rights reserved