我正在尝试设置我的 SMTP 服务器,以便它仅允许通过 SMTP 身份验证的用户发送电子邮件,但实际发送是通过 Mailjet 完成的。我正在运行,Ubuntu 14.04 LTS
Postfix 版本是mail_version = 2.9.6
如果客户端使用凭证进行身份验证 - 则会对其进行验证(如果凭证无效,则拒绝邮件)。但如果客户端未进行身份验证,则仍可以发送邮件。
请注意,我正尝试将电子邮件发送到所有域。而不仅仅是限制列表。
我如何拒绝所有未经授权的用户?
主配置文件
# 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=no
smtpd_tls_session_cache_database = btree:${data_directory}/smtpd_scache
smtp_tls_session_cache_database = btree:${data_directory}/smtp_scache
smtpd_sasl_auth_enable = yes
smtpd_sasl_security_options = noanonymous
smtpd_sasl_local_domain = mail2.xxx.cz
broken_sasl_auth_clients = yes
#smtpd_tls_auth_only = no
smtpd_delay_reject = yes
#smtpd_client_restrictions = permit_sasl_authenticated, reject
smtpd_recipient_restrictions = permit_sasl_authenticated, reject_unauth_destination, permit_mynetworks, check_r$
#permit_mynetworks, permit_sasl_authenticated, defer_unauth_destination
#permit_sasl_authenticated,
# reject_unauth_destination,
# permit_mynetworks,
# check_relay_domains
# See /usr/share/doc/postfix/TLS_README.gz in the postfix-doc package for
# information on enabling SSL in the smtp client.
myhostname = sweetparadise.cz
virtual_alias_maps = hash:/etc/postfix/virtual
virtual_alias_domains = domain1.cz domain2.cz domain3.cz
alias_database = hash:/etc/aliases
myorigin = /etc/mailname
relayhost = [in-v3.mailjet.com]:587
mynetworks = 127.0.0.0/8 192.168.137.1 [::ffff:127.0.0.0]/104 [::1]/128
home_mailbox=Maildir/
smtp_tls_security_level = encrypt
答案1
所以问题在于我使用端口转发从 Windows 主机到运行 Postfix 的虚拟机。因此所有流量都通过192.168.137.1。这导致电子邮件来自允许我的网络所以全部被接受了。