Amavis 发出的通知没有 Postfix 映射的地址

Amavis 发出的通知没有 Postfix 映射的地址

在 Amavis 发送消息到 之后,如何让 Postfix在将消息交给我的本地投递代理之前$spam_admin应用地址重写?virtual_alias_maps

我已经使用 Amavis + Spamassassin + Postfix 一段时间了,它将邮件标记为垃圾邮件,但仍将其转发。这很好。现在我决定丢弃邮件,但让 Amavis 告诉我它隔离的邮件。

当 Amavis 发现垃圾邮件时,它会丢弃该邮件,将其隔离,并发送电子邮件[email protected]通知我。该电子邮件似乎直接进入 Postfix 的pipe队列,并立即转交给 Dovecot。

问题是,这里的所有用户都使用虚拟邮箱,但没有一个邮箱postmaster(Postfixvirtual_alias_maps将其转发给实际用户)。

我如何说服 Amavis 和/或 Postfix 将消息重新路由到postmaster它们应该去的地方?

/etc/postfix/main.cf:

alias_maps = hash:/etc/aliases
alias_database = hash:/etc/aliases

# Spam and virus filtering
content_filter=smtp-amavis:[127.0.0.1]:10024

virtual_mailbox_domains = /etc/postfix/vhosts
virtual_mailbox_base = /var/vmail
virtual_mailbox_maps = hash:/etc/postfix/vmaps
virtual_minimum_uid = 1000
virtual_uid_maps = static:5000
virtual_gid_maps = static:5000

virtual_alias_maps = hash:/etc/postfix/valiases

/etc/postfix/master.cf:

# Sending to Amavis
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
  -o receive_override_options=no_address_mappings

# Returning from Amavis
127.0.0.1:10025 inet    n       -       n       -       -       smtpd
  -o content_filter=
  -o receive_override_options=no_address_mappings
  -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,no_milters,no_address_mappings

在 /etc/postfix/valiases 中:

# Many lines including...
[email protected]           [email protected]

/etc/别名

postmaster:    root
clamav: root
amavis: root

root:   [email protected]

/etc/amavis-new/conf.d/20-debian_defaults:

$final_bad_header_destiny = D_PASS;     # False-positive prone (for spam)
$final_virus_destiny      = D_DISCARD;  # (data not lost, see virus quarantine)
$final_banned_destiny     = D_REJECT;   # D_REJECT when front-end MTA
$final_spam_destiny       = D_DISCARD;

$enable_dkim_verification = 1; # was disabled to prevent warning

$virus_admin = "postmaster\@$mydomain"; # due to D_DISCARD default
$spam_admin  = "postmaster\@$mydomain"; # due to D_DISCARD default

一大块 Posfix 日志,用于处理垃圾邮件。

Nov 10 13:56:24 ogedei postfix/smtpd[23759]: connect from app-count.trade[89.33.194.137]
Nov 10 13:56:25 ogedei policyd-spf[23763]: WARNING: Deprecated Config Option defaultSeedOnly in use in: /etc/postfix-policyd-spf-python/policyd-spf.conf
Nov 10 13:56:25 ogedei policyd-spf[23763]: prepend Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=89.33.194.137; helo=app-count.trade; [email protected]; receiver=<UNKNOWN>
Nov 10 13:56:25 ogedei postfix/smtpd[23759]: 754591BCE541: client=app-count.trade[89.33.194.137]
Nov 10 13:56:25 ogedei postfix/cleanup[23764]: 754591BCE541: message-id=<MzgzNzgzNzYyNw==.3cfa6259a4253b9a20a00391147df21d@app-count.trade>
Nov 10 13:56:25 ogedei opendmarc[2635]: 754591BCE541: app-count.trade pass
Nov 10 13:56:25 ogedei postfix/qmgr[10881]: 754591BCE541: from=<[email protected]>, size=16920, nrcpt=4 (queue active)
Nov 10 13:56:25 ogedei postfix/smtpd[23759]: disconnect from app-count.trade[89.33.194.137] ehlo=1 mail=1 rcpt=1 data=1 quit=1 commands=5
Nov 10 13:56:29 ogedei postfix/smtpd[23770]: connect from localhost[127.0.0.1]
Nov 10 13:56:29 ogedei postfix/smtpd[23770]: 0FE5C1BCE542: client=localhost[127.0.0.1]
Nov 10 13:56:29 ogedei postfix/cleanup[23764]: 0FE5C1BCE542: message-id=<[email protected]>
Nov 10 13:56:29 ogedei postfix/qmgr[10881]: 0FE5C1BCE542: from=<[email protected]>, size=5335, nrcpt=1 (queue active)
Nov 10 13:56:29 ogedei postfix/smtpd[23770]: disconnect from localhost[127.0.0.1] ehlo=1 mail=1 rcpt=1 data=1 quit=1 commands=5
Nov 10 13:56:29 ogedei amavis[22288]: (22288-02) Blocked SPAM {DiscardedInbound,DiscardedOpenRelay,Quarantined}, [89.33.194.137]:44522 [89.33.194.137] <[email protected]> -> <[email protected]>, quarantine: R/spam-RsXNTL3HzvT9.gz, Queue-ID: 754591BCE541, Message-ID: <MzgzNzgzNzYyNw==.3cfa6259a4253b9a20a00391147df21d@app-count.trade>, mail_id: RsXNTL3HzvT9, Hits: 11.685, size: 17029, 3257 ms
Nov 10 13:56:29 ogedei postfix/smtp[23765]: 754591BCE541: to=<[email protected]>, orig_to=<[email protected]>, relay=127.0.0.1[127.0.0.1]:10024, delay=4, delays=0.7/0.01/0.13/3.2, dsn=2.7.0, status=sent (250 2.7.0 Ok, discarded, id=22288-02 - spam)
Nov 10 13:56:29 ogedei postfix/qmgr[10881]: 754591BCE541: removed
Nov 10 13:56:29 ogedei postfix/pipe[23771]: 0FE5C1BCE542: to=<[email protected]>, relay=dovecot, delay=0.3, delays=0.04/0/0/0.26, dsn=5.1.1, status=bounced (user unknown)
Nov 10 13:56:29 ogedei postfix/cleanup[23764]: 59C7C1BCE541: message-id=<[email protected]>
Nov 10 13:56:29 ogedei postfix/bounce[23773]: 0FE5C1BCE542: sender non-delivery notification: 59C7C1BCE541
Nov 10 13:56:29 ogedei postfix/qmgr[10881]: 59C7C1BCE541: from=<>, size=7267, nrcpt=1 (queue active)
Nov 10 13:56:29 ogedei postfix/qmgr[10881]: 0FE5C1BCE542: removed
Nov 10 13:56:29 ogedei postfix/pipe[23771]: 59C7C1BCE541: to=<[email protected]>, orig_to=<[email protected]>, relay=dovecot, delay=0.56, delays=0.42/0/0/0.15, dsn=2.0.0, status=sent (delivered via dovecot service)
Nov 10 13:56:29 ogedei postfix/qmgr[10881]: 59C7C1BCE541: removed

答案1

经过一番探索,我想我找到了答案。问题出receive_override_options=no_address_mappings在 Postfix 的“从 Amavis 返回”块中的选项上master.cf

首先,我已经receive_override_options指定了两次。哎呀!

为了解决这个问题,我no_address_mappings从 中删除了该选项receive_override_options。据我所知,推荐使用此选项纯粹是为了提高效率:在将消息传递给 Amavis 之前会重写地址,那么为什么在消息返回时再次重写它们呢?大多数情况下,这很好。但是当 Amavis 生成新的邮件(如隔离报告)时,可能需要更改该新邮件的目标地址。

当我放弃该no_address_mappings选项时,隔离通知消息[email protected](由 Amavis 生成)的地址将按照我的需要重写。

问题解决了!

修改以下部分/etc/postfix/master.cf

# Returning from Amavis
127.0.0.1:10025 inet    n       -       n       -       -       smtpd
  -o content_filter=
  # -o receive_override_options=no_address_mappings
  -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,no_milters,no_address_mappings
  -o receive_override_options=no_header_body_checks,no_unknown_recipient_checks,no_milters

相关内容