如何在postfix中加密外发邮件

时间:2017-10-07 16:05:50

标签: email ssl postfix dovecot starttls

我已经在线跟踪了几个指南后设置了postfix和dovecot,并且始终存在我发送的电子邮件不会被加密的问题。 我一直在通过向我的@ gmail.com帐户发送电子邮件来测试设置,因为我确信Google服务器将支持TLS加密,并且gmail webmail中的电子邮件清楚地显示红色划掉的挂锁以显示它们未加密。

如果我设置

smtpd_tls_security_level = encrypt
smtp_tls_security_level = encrypt 

我收到此错误

TLS is required, but was not offered by host gmail-smtp-in.l.google.com[64.233.167.27]

如果我将其设置为可能会发送电子邮件,而不加密它。

这是postconf -n

的输出
alias_database = hash:/etc/aliases
alias_maps = hash:/etc/aliases
append_dot_mydomain = no
biff = no
home_mailbox = Maildir/
inet_interfaces = all
inet_protocols = all
mailbox_command =
mailbox_size_limit = 0
mydestination = $myhostname, localdomain, localhost, localhost.localdomain, localhost, mail.example.com, example.com
myhostname = mail.example.com
mynetworks = 127.0.0.0/8 [::ffff:127.0.0.0]/104 [::1]/128
mynetworks_style = subnet
myorigin = /etc/mailname
readme_directory = no
recipient_delimiter = +
smtp_tls_CAfile = /routeto/my.ca-bundle
smtp_tls_cert_file = /routeto/my.crt
smtp_tls_key_file = /routeto/my.key
smtp_tls_loglevel = 1
smtp_tls_note_starttls_offer = yes
smtp_tls_security_level = may
smtp_tls_session_cache_database = btree:${data_directory}/smtp_scache
smtp_use_tls = yes
smtpd_banner = $myhostname ESMTP $mail_name (Ubuntu)
smtpd_client_restrictions = permit_mynetworks, permit_sasl_authenticated, reject_unknown_client_hostname
smtpd_recipient_restrictions = permit_mynetworks permit_sasl_authenticated reject_unauth_destination
smtpd_relay_restrictions = permit_mynetworks permit_sasl_authenticated defer_unauth_destination
smtpd_sasl_auth_enable = yes
smtpd_sasl_local_domain = example.com
smtpd_sasl_path = private/auth
smtpd_sasl_type = dovecot
smtpd_tls_CAfile = /routeto/my.ca-bundle
smtpd_tls_cert_file = /routeto/my.crt
smtpd_tls_key_file = /routeto/my.key
smtpd_tls_loglevel = 1
smtpd_tls_received_header = yes
smtpd_tls_security_level = may
smtpd_tls_session_cache_database = btree:${data_directory}/smtpd_scache
smtpd_use_tls = yes

这是端口25上telnet的输出,然后是ehlo test

250-mail.example.com
250-PIPELINING
250-SIZE 10240000
250-VRFY
250-ETRN
250-STARTTLS
250-AUTH PLAIN LOGIN
250-ENHANCEDSTATUSCODES
250-8BITMIME
250 DSN

和端口587上的相同内容

250-mail.example.com
250-PIPELINING
250-SIZE 10240000
250-VRFY
250-ETRN
250-STARTTLS
250-ENHANCEDSTATUSCODES
250-8BITMIME
250 DSN

1 个答案:

答案 0 :(得分:0)

  

TLS是必需的,但主机gmail-smtp-in.l.google.com不提供[64.233.167.27]

这清楚地表明,主机不向您的服务器提供STARTTLS。但是,众所周知,gmail提供STARTTLS,并且您通过telnet进行的测试确认了这一点。我的猜测是你从另一个系统做了telnet,你的邮件服务器在一些(透明)防火墙后面,它拦截流量来分析它。为了不处理加密的SMTP流量,通常只需从服务器对EHLO的响应中剥离STARTTLS命令,以便邮件服务器认为不支持TLS。

另见What happens if STARTTLS dropped in SMTP?