无法登录到 SMTP 服务器 Postfix/Imap Courier/Plesk
Posted
技术标签:
【中文标题】无法登录到 SMTP 服务器 Postfix/Imap Courier/Plesk【英文标题】:Cannot login to SMTP server Postfix/Imap Courier/Plesk 【发布时间】:2015-05-18 06:01:14 【问题描述】:我在通过 SMTP 连接到电子邮件服务器时遇到问题。
我正在尝试使用 phpMailer 发送电子邮件,这是我得到的错误:
SMTP -> get_lines(): $data was ""SMTP -> get_lines(): $str is "535 5.7.8 Error: authentication failed: encryption needed to use mechanism
"SMTP -> get_lines(): $data is "535 5.7.8 Error: authentication failed: encryption needed to use mechanism
"SMTP -> ERROR: AUTH not accepted from server: 535 5.7.8 Error: authentication failed: encryption needed to use mechanism
CLIENT -> SMTP: RSET
SMTP -> get_lines(): $data was ""SMTP -> get_lines(): $str is "250 2.0.0 Ok
"SMTP -> get_lines(): $data is "250 2.0.0 Ok
"SMTP -> FROM SERVER:250 2.0.0 Ok
exception 'phpmailerException' with message 'SMTP Error: Could not authenticate.' in C:\Projects\oicrm\protected\components\phpMailer\class.phpmailer
我用另一台邮件服务器测试过,它工作正常,所以一定是服务器配置有问题。
服务器正在运行 Postfix、Courier Imap 和 Plesk 控制面板。
还安装了fail2ban工具。
几小时前它正在运行 Dovecot 而不是 Courier,但我已将其删除并安装了 Courier,认为这会解决它,但没有运气。
我也对 Postfix master.cf 进行了调整,但没有成功。
我认为问题可能是电子邮件服务器中的配置错误,或者服务器上的 ssl/auth 问题,或者可能是某些防火墙导致问题?
刚刚尝试通过 telnet 25 连接并得到了这个:
[root@eldeposit postfix]# telnet mail.oibarcelona.com 25
Trying xxx.xxx.140.235...
Connected to xxx.xxxxxxxxx.com.
Escape character is '^]'.
220 ns334238.ip-xx-xx-xx.eu ESMTP Postfix
EHLO ns334238.ip-xx-xx-xx.eu
250-ns334238.ip-xx-xx-xx.eu
250-PIPELINING
250-SIZE 30720000
250-ETRN
250-STARTTLS
250-ENHANCEDSTATUSCODES
250-8BITMIME
250 DSN
AUTH LOGIN
503 5.5.1 Error: authentication not enabled
在这里提供我的配置:
[root@ns334238 postfix]# postconf -n
alias_database = hash:/etc/aliases
alias_maps = hash:/etc/aliases, hash:/var/spool/postfix/plesk/aliases
command_directory = /usr/sbin
config_directory = /etc/postfix
daemon_directory = /usr/libexec/postfix
data_directory = /var/lib/postfix
debug_peer_level = 2
debugger_command = PATH=/bin:/usr/bin:/usr/local/bin:/usr/X11R6/bin ddd $daemon_directory/$process_name $process_id & sleep 5
disable_vrfy_command = yes
html_directory = no
inet_interfaces = all
inet_protocols = all
mail_owner = postfix
mailbox_size_limit = 0
mailman_destination_recipient_limit = 1
mailq_path = /usr/bin/mailq.postfix
manpage_directory = /usr/share/man
message_size_limit = 30720000
mydestination = localhost.$mydomain, localhost, localhost.localdomain
myhostname = ns334238.ip-37-187-140.eu
mynetworks =
newaliases_path = /usr/bin/newaliases.postfix
plesk_virtual_destination_recipient_limit = 1
queue_directory = /var/spool/postfix
readme_directory = /usr/share/doc/postfix-2.10.1/README_FILES
sample_directory = /usr/share/doc/postfix-2.10.1/samples
sender_dependent_default_transport_maps = hash:/var/spool/postfix/plesk/sdd_transport_maps
sendmail_path = /usr/sbin/sendmail.postfix
setgid_group = postdrop
smtp_send_xforward_command = yes
smtp_tls_security_level = may
smtp_use_tls = no
smtpd_authorized_xforward_hosts = 127.0.0.0/8 [::1]/128
smtpd_client_restrictions = permit_mynetworks, permit_sasl_authenticated, reject_rbl_client zen.spamhaus.org
smtpd_milters = , inet:127.0.0.1:12768
smtpd_proxy_timeout = 3600s
smtpd_recipient_restrictions = permit_mynetworks, permit_sasl_authenticated, reject_unauth_destination
smtpd_sasl_auth_enable = yes
smtpd_sasl_security_options = noplaintext
smtpd_sender_restrictions = check_sender_access hash:/var/spool/postfix/plesk/blacklists, permit_sasl_authenticated
smtpd_timeout = 3600s
smtpd_tls_auth_only = yes
smtpd_tls_cert_file = /etc/pki/ns334238.ip-37-187-140.eu.pem
smtpd_tls_ciphers = medium
smtpd_tls_exclude_ciphers = aNULL
smtpd_tls_key_file = $smtpd_tls_cert_file
smtpd_tls_protocols = SSLv3, TLSv1
smtpd_tls_security_level = may
smtpd_use_tls = yes
transport_maps = , hash:/var/spool/postfix/plesk/transport
unknown_local_recipient_reject_code = 550
virtual_alias_maps = $virtual_maps, hash:/var/spool/postfix/plesk/virtual
virtual_gid_maps = static:31
virtual_mailbox_base = /var/qmail/mailnames
virtual_mailbox_domains = $virtual_mailbox_maps, hash:/var/spool/postfix/plesk/virtual_domains
virtual_mailbox_limit = 0
virtual_mailbox_maps = , hash:/var/spool/postfix/plesk/vmailbox
virtual_transport = plesk_virtual
virtual_uid_maps = static:30
postconf: warning: /etc/postfix/main.cf: unused parameter: tls_ssl_options=NO_COMPRESSION
还有一个:
[root@ns334238 postfix]# postconf -M
smtp inet n - n - - smtpd
pickup unix n - n 60 1 pickup
cleanup unix n - n - 0 cleanup
qmgr unix n - n 300 1 qmgr
tlsmgr unix - - n 1000? 1 tlsmgr
rewrite unix - - n - - trivial-rewrite
bounce unix - - n - 0 bounce
defer unix - - n - 0 bounce
trace unix - - n - 0 bounce
verify unix - - n - 1 verify
flush unix n - n 1000? 0 flush
proxymap unix - - n - - proxymap
proxywrite unix - - n - 1 proxymap
smtp unix - - n - - smtp
relay unix - - n - - smtp
showq unix n - n - - showq
error unix - - n - - error
retry unix - - n - - error
discard unix - - n - - discard
local unix - n n - - local
virtual unix - n n - - virtual
lmtp unix - - n - - lmtp
anvil unix - - n - 1 anvil
scache unix - - n - 1 scache
plesk_virtual unix - n n - - pipe flags=DORhu user=popuser:popuser argv=/usr/lib64/plesk-9.0/postfix-local -f $sender -d $recipient -p /var/qmail/mailnames
mailman unix - n n - - pipe flags=R user=mailman:mailman argv=/usr/lib64/plesk-9.0/postfix-mailman $nexthop $user $recipient
pickup fifo n - n 60 1 pickup
plesk_saslauthd unix y y n - 1 plesk_saslauthd status=5 listen=6 dbpath=/var/spool/postfix/plesk/passwd.db
qmgr fifo n - n 1 1 qmgr
smtps inet n - n - - smtpd -o smtpd_tls_wrappermode=yes
submission inet n - n - - smtpd -o smtpd_enforce_tls=no -o smtpd_tls_security_level=may -o smtpd_sasl_auth_enable=yes -o smtpd_client_restrictions=permit_mynetworks,permit_sasl_authenticated,reject -o smtpd_sender_restrictions= -o smtpd_recipient_restrictions=permit_mynetworks,permit_sasl_authenticated,reject_unauth_destination
plesk-example-domainbarcelona.com-XXX.XXX.XXX.XXX- unix - n n - - smtp -o smtp_bind_address=XXX.XXX.XXX.XXX -o smtp_bind_address6= -o smtp_address_preference=ipv4 -o smtp_helo_name=example-domainbarcelona.com
plesk-example-domaintrend.com-XXX.XXX.XXX.XXX- unix - n n - - smtp -o smtp_bind_address=XXX.XXX.XXX.XXX -o smtp_bind_address6= -o smtp_address_preference=ipv4 -o smtp_helo_name=example-domaintrend.com
plesk-example-domaintrend.com-XXX.XXX.XXX.XXX- unix - n n - - smtp -o smtp_bind_address=XXX.XXX.XXX.XXX -o smtp_bind_address6= -o smtp_address_preference=ipv4 -o smtp_helo_name=example-domaintrend.com
plesk-example-domainbarcelona.fr-XXX.XXX.XXX.XXX- unix - n n - - smtp -o smtp_bind_address=XXX.XXX.XXX.XXX -o smtp_bind_address6= -o smtp_address_preference=ipv4 -o smtp_helo_name=example-domainbarcelona.fr
plesk-example-domainbarcelona.co.uk-XXX.XXX.XXX.XXX- unix - n n - - smtp -o smtp_bind_address=XXX.XXX.XXX.XXX -o smtp_bind_address6= -o smtp_address_preference=ipv4 -o smtp_helo_name=example-domainbarcelona.co.uk
plesk-example-domainbarcelona.de-XXX.XXX.XXX.XXX- unix - n n - - smtp -o smtp_bind_address=XXX.XXX.XXX.XXX -o smtp_bind_address6= -o smtp_address_preference=ipv4 -o smtp_helo_name=example-domainbarcelona.de
plesk-example-domainmallorca.com-XXX.XXX.XXX.XXX- unix - n n - - smtp -o smtp_bind_address=XXX.XXX.XXX.XXX -o smtp_bind_address6= -o smtp_address_preference=ipv4 -o smtp_helo_name=example-domainmallorca.com
plesk-example-domainmgzn.com-XXX.XXX.XXX.XXX- unix - n n - - smtp -o smtp_bind_address=XXX.XXX.XXX.XXX -o smtp_bind_address6= -o smtp_address_preference=ipv4 -o smtp_helo_name=example-domainmgzn.com
plesk-example-domainmallorca.com-XXX.XXX.XXX.XXX-2001-41d0-a-4aeb-- unix - n n - - smtp -o smtp_bind_address=XXX.XXX.XXX.XXX -o smtp_bind_address6=2001:41d0:a:4aeb:: -o smtp_address_preference=ipv4 -o smtp_helo_name=example-domainmallorca.com
【问题讨论】:
【参考方案1】:刚刚自己找到了解决办法:
http://kb.sp.parallels.com/en/123719
症状
尝试使用 Roundcube 发送电子邮件时,出现错误:
SMTP Error (250): Authentication failed
通过telnet连接时,显示如下输出:
# telnet domain.tld 25
Trying 91.204.25.4...
Connected to domain.tld.
Escape character is '^]'.
220 domain.tld ESMTP Postfix
helo l
250 domain.tld
auth login
503 5.5.1 Error: authentication not enabled
邮件服务器不返回认证机制列表:
# telnet 1.2.3.4 25
Trying 1.2.3.4...
Connected to 1.2.3.4
Escape character is '^]'.
220 host.tld ESMTP Postfix
ehlo parallels.com
250-host.tld
250-PIPELINING
250-SIZE 20480000
250-ETRN
250-STARTTLS
250-ENHANCEDSTATUSCODES
250-8BITMIME
250 DSN
原因
后缀配置错误。
分辨率
检查 /etc/postfix/main.cf 中的 Postfix 配置文件。评论以下负责防止纯文本密码和强制通过 SSL 或 TLS 进行 SMTP 连接的行
#smtpd_sasl_security_options = noplaintext
#smtpd_tls_auth_only = yes
【讨论】:
您应该在您的客户端应用程序中启用 STARTTLS,而不是在您的服务器上启用不安全性。 我正在尝试使用 3 种方法进行连接,不安全、ssl 和 tls。没有工作。更改后缀配置后,所有 3 个都可以正常工作。以上是关于无法登录到 SMTP 服务器 Postfix/Imap Courier/Plesk的主要内容,如果未能解决你的问题,请参考以下文章