拒绝使用Postfix向特定收件人发送电子邮件

Modified on: Sun, 18 Aug 2019 04:20:02 +0800

所以,现在我正试图通过smtpd_recipient_restrictions设置一个外发邮件黑名单。

我遇到的问题是,当我希望系统拒绝我的测试电子邮件时,我的测试电子邮件正在发送。

这是/etc/postfix/main.cf

# See /usr/share/postfix/main.cf.dist for a commented, more complete version


# Debian specific:  Specifying a file name will cause the first
# line of that file to be used as the name.  The Debian default
# is /etc/mailname.
#myorigin = /etc/mailname

smtpd_banner = $myhostname ESMTP $mail_name (Ubuntu)
biff = no

# appending .domain is the MUA's job.
append_dot_mydomain = no

# Uncomment the next line to generate "delayed mail" warnings
#delay_warning_time = 4h

readme_directory = no

# TLS parameters
smtpd_tls_cert_file=/etc/ssl/certs/ssl-cert-snakeoil.pem
smtpd_tls_key_file=/etc/ssl/private/ssl-cert-snakeoil.key
smtpd_use_tls=yes
smtpd_tls_session_cache_database = btree:${data_directory}/smtpd_scache
smtp_tls_session_cache_database = btree:${data_directory}/smtp_scache

# See /usr/share/doc/postfix/TLS_README.gz in the postfix-doc package for
# information on enabling SSL in the smtp client.

smtpd_recipient_restrictions =
        reject_unknown_recipient_domain,
        reject_unauth_destination,
        check_recipient_access hash:/etc/postfix/recipient_block

myhostname = hostname.domain.com
alias_maps = hash:/etc/aliases
alias_database = hash:/etc/aliases
myorigin = /etc/mailname
mydestination = hostname.domain.com, hostname.domain.com, , localhost
relayhost =
mynetworks = 127.0.0.0/8 [::ffff:127.0.0.0]/104 [::1]/128
mailbox_command = procmail -a "$EXTENSION"
mailbox_size_limit = 0
recipient_delimiter = +
inet_interfaces = all

我的/etc/postfix/recipient_block(之后通过postmap运行)

personalemail@anotheroneofmydomains.com REJECT

然后,我正在发送测试邮件:

$ echo test | mail -s "test email, please ignore" personalemail@anotheroneofmydomains.com

Postfix已经重新加载了conf,已经重启了几次尝试排除故障,一切都无济于事。

来自/var/log/mail.log文件的一个块如下所示:

Sep 25 02:27:17 antares postfix/master[3024]: reload -- version 2.7.0, configuration /etc/postfix
Sep 25 02:27:27 antares postfix/pickup[3104]: C723018770: uid=1001 from=<obsidian>
Sep 25 02:27:27 antares postfix/cleanup[3110]: C723018770: message-id=<20110925092727.C723018770@hostname.domain.com>
Sep 25 02:27:27 antares postfix/qmgr[3105]: C723018770: from=<obsidian@hostname.domain.com>, size=388, nrcpt=1 (queue active)
Sep 25 02:27:28 antares postfix/smtp[3112]: C723018770: to=<personalemail@anotheroneofmydomains.com>, relay=ASPMX.L.GOOGLE.COM[74.125.47.26]:25, delay=0.35, delays=0.01/0.01/0.12/0.21, dsn=2.0.0, status=sent (250 2.0.0 OK 1316942848 j50si8227610yhe.128)
Sep 25 02:27:28 antares postfix/qmgr[3105]: C723018770: removed

......所以,我很难过。我不明白为什么电子邮件不被拒绝。

作者:damianb

最佳答案

问题是邮件是通过pickup服务(通过sendmail接口)发送的,因此它是一个“传出”邮件。对于外发邮件,smtpd_*_restrictions不适用。这些限制仅适用于通过SMTP发送的“传入”邮件。

修改强>
甚至还有Victor Duchovni(Postfix维护者)提供的解决方案:http ?://marc.info/升=后缀用户&安培; M = 120155612332393&安培; W = 1


相关问答

添加新评论