使用外部 SMTP 服务器设置 Postfix

使用外部 SMTP 服务器设置 Postfix

我正在尝试在 Ubuntu 14.04 上设置 postfix 以使用外部 SMTP 服务器。

我安装了libsasl2-modules来处理身份验证。

我创建了我的凭证文件:

sudo vim /etc/postfix/sasl_passwd

使用:

[mail.mydomain.com]:587 username:password

创建哈希数据库:

sudo postmap /etc/postfix/sasl_passwd

使用此设置在/etc/postfix/main.cf

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

smtpd_relay_restrictions = permit_mynetworks permit_sasl_authenticated defer_unauth_destination
#myhostname = web.mydomain.com
mydomain = mydomain.com
alias_maps = hash:/etc/aliases
alias_database = hash:/etc/aliases
myorigin = /etc/mailname
mydestination = www.mydomain.com, web.mydomain.com, localhost.mydomain.com, localhost
relayhost = [mail.mydomain.com]:587
mynetworks = 127.0.0.0/8 [::ffff:127.0.0.0]/104 [::1]/128
mailbox_size_limit = 0
recipient_delimiter = +
inet_interfaces = all
inet_protocols = all

# enable SASL authentication 
smtp_sasl_auth_enable = yes
# disallow methods that allow anonymous authentication. 
smtp_sasl_security_options = noanonymous
# where to find sasl_passwd
smtp_sasl_password_maps = hash:/etc/postfix/sasl_passwd
# Enable STARTTLS encryption 
smtp_use_tls = yes
# where to find CA certificates
smtp_tls_CAfile = /etc/ssl/certs/ca-certificates.crt

但是,每当我发送测试邮件时,身份验证都会失败,因为postfix没有使用我的凭据,sasl_passwd而是使用当前用户。请检查我的/var/log/mail.log

Mar  4 09:10:20 web postfix/smtp[9214]: 4087042522: to=<[email protected]>, relay=mail.mydomain.com[xx.xx.xxx.xx]:587, delay=4.9, delays=4.8/0.01/0.12/0.01, dsn=5.0.0, status=bounced (host mail.mydomain.com[xx.xx.xxx.xx] said: 550-Verification failed for <[email protected]> 550-No Such User Here 550 Sender verify failed (in reply to RCPT TO command))

Verification failed for <[email protected]>当我想在 sasl_passwd 中使用我的用户名:密码时。

我找不到有关如何深入研究这个问题的文档。为什么postfix不使用 sasl_passw 文件?

答案1

对于遇到同样问题的人,我只需在我的 ISP 上为机器中的每个用户创建电子邮件帐户即可发送电子邮件([email protected][email protected][email protected])并正常工作。

相关内容