Email

Amavis 到 Postfix 轉發

  • January 19, 2015

我有一個 postfix 郵件伺服器,想使用 amavis 進行垃圾郵件和病毒檢測。我按照教程將 amavis 添加到我正在執行的郵件伺服器中。我添加到/etc/postfix/main.cf:

content_filter = smtp-amavis:[127.0.0.1]:10024

我的 /etc/postfix/master.cf 像這樣鎖定:

smtp      inet  n       -       -       -       -       smtpd
submission inet n       -       -       -       -       smtpd -v
 -o syslog_name=postfix/submission
 -o smtpd_tls_security_level=encrypt
 -o smtpd_sasl_type=dovecot
 -o smtpd_sasl_path=private/auth
 -o smtpd_sasl_security_options=noanonymous
 -o smtpd_sasl_auth_enable=yes
 -o smtpd_client_restrictions=permit_sasl_authenticated,reject

pickup    unix  n       -       -       60      1       pickup
 -o content_filter=
 -o receive_override_options=no_header_body_checks
cleanup   unix  n       -       -       -       0       cleanup
qmgr      unix  n       -       n       300     1       qmgr
#qmgr     unix  n       -       n       300     1       oqmgr
tlsmgr    unix  -       -       -       1000?   1       tlsmgr
rewrite   unix  -       -       -       -       -       trivial-rewrite
bounce    unix  -       -       -       -       0       bounce
defer     unix  -       -       -       -       0       bounce
trace     unix  -       -       -       -       0       bounce
verify    unix  -       -       -       -       1       verify
flush     unix  n       -       -       1000?   0       flush
proxymap  unix  -       -       n       -       -       proxymap
proxywrite unix -       -       n       -       1       proxymap
smtp      unix  -       -       -       -       -       smtp
relay     unix  -       -       -       -       -       smtp
#       -o smtp_helo_timeout=5 -o smtp_connect_timeout=5
showq     unix  n       -       -       -       -       showq
error     unix  -       -       -       -       -       error
retry     unix  -       -       -       -       -       error
discard   unix  -       -       -       -       -       discard
local     unix  -       n       n       -       -       local
virtual   unix  -       n       n       -       -       virtual
lmtp      unix  -       -       -       -       -       lmtp
anvil     unix  -       -       -       -       1       anvil
scache    unix  -       -       -       -       1       scache

maildrop  unix  -       n       n       -       -       pipe
 flags=DRhu user=vmail argv=/usr/bin/maildrop -d ${recipient}

uucp      unix  -       n       n       -       -       pipe
 flags=Fqhu user=uucp argv=uux -r -n -z -a$sender - $nexthop!rmail ($recipient)
ifmail    unix  -       n       n       -       -       pipe
 flags=F user=ftn argv=/usr/lib/ifmail/ifmail -r $nexthop ($recipient)
bsmtp     unix  -       n       n       -       -       pipe
 flags=Fq. user=bsmtp argv=/usr/lib/bsmtp/bsmtp -t$nexthop -f$sender $recipient
scalemail-backend unix  -       n       n       -       2       pipe
 flags=R user=scalemail argv=/usr/lib/scalemail/bin/scalemail-store ${nexthop} ${user} ${extension}
mailman   unix  -       n       n       -       -       pipe
 flags=FR user=list argv=/usr/lib/mailman/bin/postfix-to-mailman.py
 ${nexthop} ${user}

smtp-amavis unix         -       -       n       -       2       smtp
 -o smtp_data_done_timeout=1200
 -o smtp_send_xforward_command=yes
 -o disable_dns_lookups=yes
 -o max_use=20
##### Amavis inbound properties ######
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_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 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

postconf -n 的輸出:

append_dot_mydomain = no
biff = no
config_directory = /etc/postfix
content_filter = smtp-amavis:[127.0.0.1]:10024
inet_interfaces = all
inet_protocols = all
local_recipient_maps = $virtual_mailbox_maps
mailbox_size_limit = 0
mydestination =
mynetworks = 127.0.0.0/8 [::ffff:127.0.0.0]/104 [::1]/128
myorigin = mydomain.com
readme_directory = no
recipient_delimiter =
smtp_tls_session_cache_database = btree:${data_directory}/smtp_scache
smtpd_banner = $myhostname ESMTP $mail_name (Ubuntu)
smtpd_relay_restrictions = permit_mynetworks, permit_sasl_authenticated, reject_unauth_destination
smtpd_sasl_auth_enable = yes
smtpd_sasl_path = private/auth
smtpd_sasl_type = dovecot
smtpd_tls_cert_file = /etc/ssl/certs/ssl-cert-snakeoil.pem
smtpd_tls_key_file = /etc/ssl/private/ssl-cert-snakeoil.key
smtpd_tls_mandatory_protocols = !SSLv2, !SSLv3
smtpd_tls_session_cache_database = btree:${data_directory}/smtpd_scache
smtpd_use_tls = yes
virtual_mailbox_domains = mydomain.com
virtual_mailbox_maps = ldap:/etc/postfix/virtual/ldap-maps.cf
virtual_transport = lmtp:unix:private/dovecot-lmtp

我嘗試發送的所有郵件都使用此日誌資訊延遲獲取狀態:

   Jan 19 10:28:51 mydomain postfix/smtp[2035]: BB27526F73: to=<user@mydomain.com>, relay=127.0.0.1[127.0.0.1]:10024, delay=2.7, delays=0.13/0.01/0/2.5, dsn=4.5.0, status=deferred (host 127.0.0.1[127.0.0.1] said: 451 4.5.0 id=00944-02 - Temporary MTA failure on relaying, From MTA() during fwd-connect (Negative greeting:  at (eval 134) line 479.): id=00944-02 (in reply to end of DATA command))

如果我重新排隊延遲的郵件,它將被傳遞。但是之前沒有排隊的所有新郵件都會獲得相同的狀態和相同的問題。

有人知道如何解決這個問題嗎?

編輯:這是我的日誌中的幾行,以及重新排隊郵件後的日誌:

Jan 19 13:45:13 mydomain postfix/smtpd[2361]: fatal: unexpected command-line argument: ###
Jan 19 13:45:14 mydomain postfix/master[2014]: warning: process /usr/lib/postfix/smtpd pid 2361 exit status 1
Jan 19 13:45:14 mydomain postfix/master[2014]: warning: /usr/lib/postfix/smtpd: bad command startup -- throttling
Jan 19 13:45:14 mydomain amavis[943]: (00943-06) (!)FWD from <alice@mydomain.com> -> <bob@mydomain.com>, 451 4.5.0 From MTA() during fwd-connect (Negative greeting:  at (eval 134) line 479.): id=00943-06
Jan 19 13:45:14 mydomain amavis[943]: (00943-06) Blocked MTA-BLOCKED {TempFailedInbound}, [xxx.xxx.xxx.xxx]:50237 [xxx.xxx.xxx.xxx] <alice@mydomain.com> -> <bob@mydomain.com>, Queue-ID: 53094271AF, Message-ID: <54BCFC56.3030600@mydomain.com>, mail_id: eK3SxABQEng1, Hits: 1.438, size: 608, 2797 ms
Jan 19 13:45:14 mydomain postfix/smtp[2357]: 53094271AF: to=<bob@mydomain.com>, relay=127.0.0.1[127.0.0.1]:10024, delay=2.9, delays=0.12/0.01/0/2.8, dsn=4.5.0, status=deferred (host 127.0.0.1[127.0.0.1] said: 451 4.5.0 id=00943-06 - Temporary MTA failure on relaying, From MTA() during fwd-connect (Negative greeting:  at (eval 134) line 479.): id=00943-06 (in reply to end of DATA command))
Jan 19 13:45:16 mydomain postfix/submission/smtpd[2355]: auto_clnt_close: disconnect private/tlsmgr stream
Jan 19 13:45:16 mydomain postfix/submission/smtpd[2355]: rewrite stream disconnect
Jan 19 13:45:24 mydomain postfix/postsuper[2364]: Requeued: 1 message
Jan 19 13:45:49 mydomain postfix/pickup[2293]: 00D21271BA: uid=107 from=<alice@mydomain.com> orig_id=53094271AF
Jan 19 13:45:49 mydomain postfix/cleanup[2348]: 00D21271BA: message-id=<54BCFC56.3030600@mydomain.com>
Jan 19 13:45:49 mydomain postfix/qmgr[2018]: 00D21271BA: from=<alice@mydomain.com>, size=727, nrcpt=1 (queue active)
Jan 19 13:45:49 mydomain dovecot: lmtp(2369): Connect from local
Jan 19 13:45:49 mydomain dovecot: lmtp(2369, bob@mydomain.com): wlQ8AX38vFRBCQAAXzmN0w: msgid=<54BCFC56.3030600@mydomain.com>: saved mail to INBOX
Jan 19 13:45:49 mydomain postfix/lmtp[2368]: 00D21271BA: to=<bob@mydomain.com>, relay=mydomain.localdomain[private/dovecot-lmtp], delay=38, delays=38/0.01/0/0.01, dsn=2.0.0, status=sent (250 2.0.0 <bob@mydomain.com> wlQ8AX38vFRBCQAAXzmN0w Saved)
Jan 19 13:45:49 mydomain dovecot: lmtp(2369): Disconnect from local: Successful quit
Jan 19 13:45:49 mydomain postfix/qmgr[2018]: 00D21271BA: removed

哎,感覺自己好傻。。。

發現了錯誤。masegaloeh 感謝您的提示,並為所有因我的愚蠢而浪費時間的人感到抱歉…

我只是在我的 master.cf 中有一個錯誤的評論,在我在這裡發佈內容之前我刪除了它,所以我的原始 master.cf 文件被鎖定如下:

##### Amavis inbound properties ######
127.0.0.1:10025 inet n - n - - smtpd  ### stupid commend :(
 -o content_filter=
 -o local_recipient_maps=

Thia 郵件日誌行

Jan 19 13:45:13 mydomain postfix/smtpd[2361]: fatal: unexpected command-line argument: ###

清楚地表明master.cf語法有問題。您已經在回答中確認了這一點。在這一部分中,我將嘗試解釋為什麼郵件在重新排隊時會通過。

當您發出postsuper - r重新排隊消息的命令時,postfix 會將電子郵件移動到 maildrop 隊列。然後pickup守護程序將“挑選”它並嘗試傳遞它。在另一部分中,您在拾取過程中禁用了 amavis content_filter(通過 master.cf)。因此,重新排隊的電子郵件不會通過 amavis,因此不會出現上述錯誤消息。

引用自:https://serverfault.com/questions/660580