Postfix 发件人地址被拒绝/使用多个地址

Postfix 发件人地址被拒绝/使用多个地址

我有一台运行 Postfix 的电子邮件服务器,总体来说运行良好。我尝试将此服务器用作 CRM/营销平台安装中用于发送邮件的 SMTP 服务器。我输入了身份验证凭据,它运行良好。但是,我只能使用用于身份验证的邮箱作为“发件人”地址。如果我尝试在活动中使用不同的地址(在同一域中),则发送失败并导致此错误:

由于以下原因,此消息在 3 次尝试后无法送达:错误消息:来自服务器 220 server.com 250-server.com 250-PIPELINING 250-SIZE 26214400 250-ETRN 250-STARTTLS 250-ENHANCEDSTATUSCODES 250-8BITMIME 250 DSN 220 2.0.0 的响应已准备好启动 TLS 250-server.com 250-PIPELINING 250-SIZE 26214400 250-ETRN 250-AUTH PLAIN LOGIN 250-AUTH=PLAIN LOGIN 250-ENHANCEDSTATUSCODES 250-8BITMIME 250 DSN 334 VXNlcm5hbWU6 334 UGFzc3dvcmQ6 235 2.7.0 认证成功 250 2.1.0 确定 553 5.7.1 :发件人地址被拒绝:不属于用户[电子邮件保护]250 2.0.0 好的。

有没有办法配置 Postfix,允许我在通过一个帐户进行身份验证后从这个特定域上的任何地址发送邮件?我可以为这个正在验证的用户分配地址吗?我不想在其他域上打开它,只想在这个用于此 CRM 的特定域上打开它。

谢谢!

--

以下是postconf -n我得到的信息:

alias_database = hash:/etc/aliases
alias_maps = hash:/etc/aliases
append_dot_mydomain = no
biff = no
bounce_queue_lifetime = 1d
broken_sasl_auth_clients = yes
config_directory = /etc/postfix
disable_vrfy_command = yes
html_directory = /usr/share/doc/postfix/html
inet_interfaces = all
inet_protocols = all
mailbox_size_limit = 0
maximal_backoff_time = 1800s
maximal_queue_lifetime = 1d
message_size_limit = 26214400
milter_default_action = accept
milter_protocol = 6
minimal_backoff_time = 300s
mydestination = mail1.mydomain.com, localhost.mydomain.com, localhost
myhostname = mail1.mydomain.com
mynetworks = 127.0.0.0/8 [::ffff:127.0.0.0]/104 [::1]/128
myorigin = /etc/mailname
postscreen_access_list = permit_mynetworks, cidr:/etc/postfix/postscreen_access.cidr
postscreen_bare_newline_enable = no
postscreen_blacklist_action = drop
postscreen_cache_cleanup_interval = 24h
postscreen_cache_map = proxy:btree:$data_directory/postscreen_cache
postscreen_dnsbl_action = enforce
postscreen_dnsbl_sites = b.barracudacentral.org=127.0.0.2*7 dnsbl.inps.de=127.0.0.2*7 bl.mailspike.net=127.0.0.2*5 bl.mailspike.net=127.0.0.[10;11;12]*4 dnsbl.sorbs.net=127.0.0.10*8 dnsbl.sorbs.net=127.0.0.5*6 dnsbl.sorbs.net=127.0.0.7*3 dnsbl.sorbs.net=127.0.0.8*2 dnsbl.sorbs.net=127.0.0.6*2 dnsbl.sorbs.net=127.0.0.9*2 zen.spamhaus.org=127.0.0.[10;11]*8 zen.spamhaus.org=127.0.0.[4..7]*6 zen.spamhaus.org=127.0.0.3*4 zen.spamhaus.org=127.0.0.2*3 hostkarma.junkemailfilter.com=127.0.0.2*3 hostkarma.junkemailfilter.com=127.0.0.4*1 hostkarma.junkemailfilter.com=127.0.1.2*1 wl.mailspike.net=127.0.0.[18;19;20]*-2 hostkarma.junkemailfilter.com=127.0.0.1*-2
postscreen_dnsbl_threshold = 8
postscreen_dnsbl_ttl = 5m
postscreen_greet_action = enforce
postscreen_greet_banner = $smtpd_banner
postscreen_greet_ttl = 2d
postscreen_greet_wait = 3s
postscreen_non_smtp_command_enable = no
postscreen_pipelining_enable = no
proxy_read_maps = $local_recipient_maps $mydestination $virtual_alias_maps $virtual_alias_domains $virtual_mailbox_maps $virtual_mailbox_domains $relay_recipient_maps $relay_domains $canonical_maps $sender_canonical_maps $recipient_canonical_maps $relocated_maps $transport_maps $mynetworks $smtpd_sender_login_maps
queue_run_delay = 300s
readme_directory = /usr/share/doc/postfix
recipient_delimiter = +
relay_domains = proxy:mysql:/etc/postfix/sql/mysql_virtual_mxdomain_maps.cf
relay_recipient_maps = proxy:mysql:/etc/postfix/sql/mysql_virtual_alias_maps.cf
relayhost =
smtp_header_checks = pcre:/etc/postfix/mailcow_anonymize_headers.pcre
smtp_tls_CAfile = /etc/ssl/certs/ca-certificates.crt
smtp_tls_cert_file = /etc/ssl/mail/mail.crt
smtp_tls_key_file = /etc/ssl/mail/mail.key
smtp_tls_loglevel = 1
smtp_tls_security_level = may
smtp_tls_session_cache_database = btree:${data_directory}/smtp_scache
smtpd_banner = $myhostname
smtpd_data_restrictions = reject_unauth_pipelining, permit
smtpd_delay_reject = yes
smtpd_error_sleep_time = 10s
smtpd_hard_error_limit = ${stress?1}${stress:5}
smtpd_helo_required = yes
smtpd_proxy_timeout = 600s
smtpd_recipient_restrictions = permit_sasl_authenticated, permit_mynetworks, reject_invalid_helo_hostname, reject_unknown_reverse_client_hostname, reject_unknown_client_hostname, reject_non_fqdn_helo_hostname, reject_unauth_destination, reject_rbl_client zen.spamhaus.org, reject_rbl_client bl.spamcop.net, reject_rbl_client cbl.abuseat.org, reject_rbl_client b.barracudacentral.org
smtpd_restriction_classes = z1_greylisting
smtpd_sasl_auth_enable = yes
smtpd_sasl_authenticated_header = yes
smtpd_sasl_path = private/auth_dovecot
smtpd_sasl_type = dovecot
smtpd_sender_login_maps = proxy:mysql:/etc/postfix/sql/mysql_virtual_sender_acl.cf, proxy:mysql:/etc/postfix/sql/mysql_virtual_alias_maps.cf
smtpd_sender_restrictions = reject_authenticated_sender_login_mismatch, permit_mynetworks, reject_sender_login_mismatch, permit_sasl_authenticated, reject_unlisted_sender, reject_unknown_sender_domain
smtpd_soft_error_limit = 3
smtpd_tls_auth_only = yes
smtpd_tls_cert_file = /etc/ssl/mail/mail.crt
smtpd_tls_dh1024_param_file = /etc/ssl/mail/dhparams.pem
smtpd_tls_eecdh_grade = strong
smtpd_tls_exclude_ciphers = ECDHE-RSA-RC4-SHA
smtpd_tls_key_file = /etc/ssl/mail/mail.key
smtpd_tls_loglevel = 1
smtpd_tls_mandatory_ciphers = high
smtpd_tls_mandatory_exclude_ciphers = ECDHE-RSA-RC4-SHA
smtpd_tls_mandatory_protocols = !SSLv2, !SSLv3
smtpd_tls_security_level = may
smtpd_tls_session_cache_database = btree:${data_directory}/smtpd_scache
tls_high_cipherlist = EDH+CAMELLIA:EDH+aRSA:EECDH+aRSA+AESGCM:EECDH+aRSA+SHA384:EECDH+aRSA+SHA256:EECDH:+CAMELLIA256:+AES256:+CAMELLIA128:+AES128:+SSLv3:!aNULL:!eNULL:!LOW:!3DES:!MD5:!EXP:!PSK:!DSS:!RC4:!SEED:!ECDSA:CAMELLIA256-SHA:AES256-SHA:CAMELLIA128-SHA:AES128-SHA
virtual_alias_maps = proxy:mysql:/etc/postfix/sql/mysql_virtual_alias_maps.cf, proxy:mysql:/etc/postfix/sql/mysql_virtual_spamalias_maps.cf, proxy:mysql:/etc/postfix/sql/mysql_virtual_alias_domain_maps.cf, proxy:mysql:/etc/postfix/sql/mysql_virtual_alias_domain_catchall_maps.cf
virtual_gid_maps = static:5000
virtual_mailbox_base = /var/vmail/
virtual_mailbox_domains = proxy:mysql:/etc/postfix/sql/mysql_virtual_domains_maps.cf
virtual_mailbox_maps = proxy:mysql:/etc/postfix/sql/mysql_virtual_mailbox_maps.cf, proxy:mysql:/etc/postfix/sql/mysql_virtual_alias_domain_mailbox_maps.cf
virtual_minimum_uid = 104
virtual_transport = lmtp:unix:private/dovecot-lmtp
virtual_uid_maps = static:5000
z1_greylisting = permit_dnswl_client list.dnswl.org, check_policy_service inet:127.0.0.1:10023

以下是mysql_virtual_sender_acl.cf

# mysql_virtual_sender_acl.cf
user = mailcow
password = password
hosts = localhost
dbname = mailcow
query = SELECT logged_in_as FROM sender_acl WHERE send_as='%s'
#expansion_limit = 100

并且mysql_virtual_alias_maps.cf

# mysql_virtual_alias_maps.cf
user = mailcow
password = password
hosts = localhost
dbname = mailcow
query = SELECT goto FROM alias WHERE address='%s' AND active = '1'
#expansion_limit = 100

答案1

您可以使用拒绝经过身份验证的发送者登录不匹配

让用户进行测试

# saslpasswd2 -c -u example.net user1
# saslpasswd2 -c -u example.com user2

# sasldblistusers2
[email protected]: userPassword
[email protected]: userPassword

进行一些基本测试。如您所见,没有reject_authenticated_sender_login_mismatch的用户可以使用邮件来自无论他想要什么

# echo "Hello world" | swaks -s 127.0.0.1 --from [email protected] --to [email protected] --h-Subject "Test" --auth PLAIN --auth-user user1 --auth-password 1234567 --body -
=== Trying 127.0.0.1:25...
=== Connected to 127.0.0.1.
<-  220 mail.example.net ESMTP Postfix
 -> EHLO svn.example.net
<-  250-mail.example.net
<-  250-PIPELINING
<-  250-SIZE 10240000
<-  250-VRFY
<-  250-ETRN
<-  250-AUTH LOGIN PLAIN
<-  250-ENHANCEDSTATUSCODES
<-  250-8BITMIME
<-  250 DSN
 -> AUTH PLAIN AHVzZXIxADEyMzQ1Njc=
<-  235 2.7.0 Authentication successful
 -> MAIL FROM:<[email protected]>
<-  250 2.1.0 Ok
 -> RCPT TO:<[email protected]>
<-  250 2.1.5 Ok
 -> DATA
<-  354 End data with <CR><LF>.<CR><LF>
 -> Date: Thu, 25 Feb 2016 20:53:45 +0000
 -> To: [email protected]
 -> From: [email protected]
 -> Subject: Test
 -> X-Mailer: swaks v20130209.0 jetmore.org/john/code/swaks/
 ->
 -> Hello world
 ->
 ->
 -> .
<-  250 2.0.0 Ok: queued as E1D3D406CC
 -> QUIT
<-  221 2.0.0 Bye
=== Connection closed with remote host.

# grep E1D3D406CC /var/log/maillog
Feb 25 20:53:45 svn postfix/smtpd[56996]: E1D3D406CC: client=localhost[127.0.0.1], sasl_method=PLAIN, [email protected]
Feb 25 20:53:45 svn postfix/cleanup[56999]: E1D3D406CC: message-id=<[email protected]>
Feb 25 20:53:45 svn postfix/qmgr[56990]: E1D3D406CC: from=<[email protected]>, size=416, nrcpt=1 (queue active)
Feb 25 20:53:45 svn postfix/local[57000]: E1D3D406CC: to=<[email protected]>, relay=local, delay=0.03, delays=0.02/0/0/0.01, dsn=2.0.0, status=sent (delivered to mailbox)
Feb 25 20:53:45 svn postfix/qmgr[56990]: E1D3D406CC: removed

# echo "Hello world" | swaks -s 127.0.0.1 --from [email protected] --to [email protected] --h-Subject "Test" --auth PLAIN --auth-user user1 --auth-password 1234567 --body -
=== Trying 127.0.0.1:25...
=== Connected to 127.0.0.1.
<-  220 mail.example.net ESMTP Postfix
 -> EHLO svn.example.net
<-  250-mail.example.net
<-  250-PIPELINING
<-  250-SIZE 10240000
<-  250-VRFY
<-  250-ETRN
<-  250-AUTH LOGIN PLAIN
<-  250-ENHANCEDSTATUSCODES
<-  250-8BITMIME
<-  250 DSN
 -> AUTH PLAIN AHVzZXIxADEyMzQ1Njc=
<-  235 2.7.0 Authentication successful
 -> MAIL FROM:<[email protected]>
<-  250 2.1.0 Ok
 -> RCPT TO:<[email protected]>
<-  250 2.1.5 Ok
 -> DATA
<-  354 End data with <CR><LF>.<CR><LF>
 -> Date: Thu, 25 Feb 2016 20:55:13 +0000
 -> To: [email protected]
 -> From: [email protected]
 -> Subject: Test
 -> X-Mailer: swaks v20130209.0 jetmore.org/john/code/swaks/
 ->
 -> Hello world
 ->
 ->
 -> .
<-  250 2.0.0 Ok: queued as 94CBF4076C
 -> QUIT
<-  221 2.0.0 Bye
=== Connection closed with remote host.

# grep 94CBF4076C /var/log/maillog
Feb 25 20:55:13 svn postfix/smtpd[56996]: 94CBF4076C: client=localhost[127.0.0.1], sasl_method=PLAIN, [email protected]
Feb 25 20:55:13 svn postfix/cleanup[56999]: 94CBF4076C: message-id=<[email protected]>
Feb 25 20:55:13 svn postfix/qmgr[56990]: 94CBF4076C: from=<[email protected]>, size=424, nrcpt=1 (queue active)
Feb 25 20:55:13 svn postfix/local[57000]: 94CBF4076C: to=<[email protected]>, relay=local, delay=0.01, delays=0.01/0/0/0, dsn=2.0.0, status=sent (delivered to mailbox)
Feb 25 20:55:13 svn postfix/qmgr[56990]: 94CBF4076C: removed

但在我们添加了以下几行之后

# /etc/postfix/main.cf

smtpd_sender_login_maps = hash:/etc/postfix/sender_logins_maps
smtpd_sender_restrictions = reject_authenticated_sender_login_mismatch

不要忘记创建地图并重新启动 postfix

# postmap /etc/postfix/sender_logins_maps
# service postfix restart

# cat /etc/postfix/sender_logins_maps
[email protected] [email protected]
[email protected] [email protected]
[email protected] [email protected]

用户不能再使用他想要的任何东西

# echo "Hello world" | swaks -s 127.0.0.1 --from [email protected] --to [email protected] --h-Subject "Test" --auth PLAIN --auth-user user1 --auth-password 1234567 --body -
=== Trying 127.0.0.1:25...
=== Connected to 127.0.0.1.
<-  220 mail.example.net ESMTP Postfix
 -> EHLO svn.example.net
<-  250-mail.example.net
<-  250-PIPELINING
<-  250-SIZE 10240000
<-  250-VRFY
<-  250-ETRN
<-  250-AUTH LOGIN PLAIN
<-  250-ENHANCEDSTATUSCODES
<-  250-8BITMIME
<-  250 DSN
 -> AUTH PLAIN AHVzZXIxADEyMzQ1Njc=
<-  235 2.7.0 Authentication successful
 -> MAIL FROM:<[email protected]>
<-  250 2.1.0 Ok
 -> RCPT TO:<[email protected]>
<** 553 5.7.1 <[email protected]>: Sender address rejected: not owned by user user1
 -> QUIT
<-  221 2.0.0 Bye
=== Connection closed with remote host.

但使用上述设置[电子邮件保护]仅可以在 MAIL FROM 中使用:[电子邮件保护][电子邮件保护][电子邮件保护]

# echo "Hello world" | swaks -s 127.0.0.1 --from [email protected] --to [email protected] --h-Subject "Test" --auth PLAIN --auth-user [email protected] --auth-password 1234567 --body -
=== Trying 127.0.0.1:25...
=== Connected to 127.0.0.1.
<-  220 mail.example.net ESMTP Postfix
 -> EHLO svn.example.net
<-  250-mail.example.net
<-  250-PIPELINING
<-  250-SIZE 10240000
<-  250-VRFY
<-  250-ETRN
<-  250-AUTH LOGIN PLAIN
<-  250-ENHANCEDSTATUSCODES
<-  250-8BITMIME
<-  250 DSN
 -> AUTH PLAIN AHVzZXIxQGV4YW1wbGUubmV0ADEyMzQ1Njc=
<-  235 2.7.0 Authentication successful
 -> MAIL FROM:<[email protected]>
<-  250 2.1.0 Ok
 -> RCPT TO:<[email protected]>
<-  250 2.1.5 Ok
 -> DATA
<-  354 End data with <CR><LF>.<CR><LF>
 -> Date: Thu, 25 Feb 2016 23:03:07 +0000
 -> To: [email protected]
 -> From: [email protected]
 -> Subject: Test
 -> X-Mailer: swaks v20130209.0 jetmore.org/john/code/swaks/
 ->
 -> Hello world
 ->
 ->
 -> .
<-  250 2.0.0 Ok: queued as 9FE524068A
 -> QUIT
<-  221 2.0.0 Bye
=== Connection closed with remote host.

# grep 9FE524068A /var/log/maillog
Feb 25 23:03:07 svn postfix/smtpd[19097]: 9FE524068A: client=localhost[127.0.0.1], sasl_method=PLAIN, [email protected]
Feb 25 23:03:07 svn postfix/cleanup[19100]: 9FE524068A: message-id=<[email protected]>
Feb 25 23:03:07 svn postfix/qmgr[19092]: 9FE524068A: from=<[email protected]>, size=419, nrcpt=1 (queue active)
Feb 25 23:03:07 svn postfix/local[19101]: 9FE524068A: to=<[email protected]>, relay=local, delay=0.01, delays=0.01/0/0/0, dsn=2.0.0, status=sent (delivered to mailbox)
Feb 25 23:03:07 svn postfix/qmgr[19092]: 9FE524068A: removed

PS一个小技巧

如果没有在 /etc/postfix/sender_logins_maps 中为某些特定用户添加任何行 - 他将收到电子邮件但不会发送。

我似乎无法运行 saslauthd。它说找不到命令。这是一个单独的实用程序吗?编辑:抱歉,我的意思是说 testsaslauthd。两者都不起作用

这只是一个测试。因此,为了快速设置测试环境,我选择了 sasldb。因为我没有时间设置和配置 MySQL。您正在使用 MySQL 来存储有关用户的所有信息。您的限制在此处描述

smtpd_sender_login_maps = 
 proxy:mysql:/etc/postfix/sql/mysql_virtual_sender_acl.cf
 proxy:mysql:/etc/postfix/sql/mysql_virtual_alias_maps.cf

您应该将 mysql_virtual_sender_acl.cf/mysql_virtual_alias_maps.cf 的内容(当然没有密码)添加到问题中

有没有办法配置 Postfix 以允许我通过一个帐户进行身份验证后从这个特定域上的任何地址发送?

在 /etc/postfix/sender_logins_maps 中你应该有类似以下内容

@example.net [email protected]

修改 smtpd_sender_login_maps

smtpd_sender_login_maps = 
 hash:/etc/postfix/sender_logins_maps,
 proxy:mysql:/etc/postfix/sql/mysql_virtual_sender_acl.cf, 
 proxy:mysql:/etc/postfix/sql/mysql_virtual_alias_maps.cf

文件 /etc/postfix/sender_logins_maps 应该只包含一行

@example.net [email protected]

其中 @example.net - “一个特定的域名”, [电子邮件保护]- “使用一个帐户进行身份验证”。必须是 sasl_username!

sasl_method=PLAIN, [email protected]

不要忘记创建地图并重新启动 postfix。

答案2

似乎你已经设置了拒绝发送者登录不匹配

您可以使用smtpd_sender_login_maps配置哪些用户可以从特定发件人或域发送。

Postfix 文档给出了一个例子这里(参见信封发件人地址授权)。

更新 1:

以下是 smtpd_sender_login_maps(哈希图)的示例。这依赖于后缀在与地图匹配时的查找顺序。迭代如下

  1. [电子邮件保护]
  2. @server.com

因此你需要注入一个哈希表,将域名的账户列入白名单,如下所示

@server.com [email protected]

这只是表明第二个查找后缀将执行此操作(第一个是与[电子邮件保护]) 将命中哈希图。 重要的 如果还有其他映射(取自注释,mysql 中有映射)首先命中,则已经做出决定(第一次匹配)并且不会执行第二次查找。

为了授予帐户“以任何 @server.com 身份发送”权限[电子邮件保护]mysql 必须将其列在帐户的允许所有者上(实际帐户除外),或者 mysql 已明确不是列出该帐户(以便第二次查找迭代命中哈希图)。

修改内容后不要忘记对哈希图进行 postmap(cd 到文件目录并对文件进行 postmap)

相关内容