由于 gmail 中外发邮件的限制,我在我的一台服务器上安装了 exim4,设置如下:
dc_eximconfig_configtype='internet'
dc_other_hostnames='mydomain.com, localhost, localhost.localdomain, mail.mydomain.com'
dc_local_interfaces=''
dc_readhost='mydomain.com'
dc_relay_domains=''
dc_minimaldns='false'
dc_relay_nets=''
dc_smarthost='mydomain.com'
CFILEMODE='644'
dc_use_split_config='false'
dc_hide_mailname='true'
dc_mailname_in_oh='true'
dc_localdelivery='maildir_home'
我还更改了防火墙设置以允许 SMTP 连接。现在我可以使用如下命令从该服务器发送邮件:
echo "TEST" | mail -s testing user@example.com
现在我想使用这个服务器为我的另一个远程服务器发送邮件,比如 mydomain2.com。我在第二台服务器上使用 django。settings.py 文件的当前设置如下:
EMAIL_HOST = 'mail.mydomain.com'
EMAIL_HOST_USER = 'username' # username of one of my user on the first server
EMAIL_HOST_PASSWORD = 'password'
EMAIL_PORT = 25
EMAIL_USE_TLS = True
当我尝试使用上述设置和以下代码从该服务器发送邮件时:
from django.core.mail import send_mail
send_mail('testing','test','from@example.com',['to@example.com'])
我收到以下错误:
Traceback (most recent call last):
File "<console>", line 1, in <module>
File "/usr/local/lib/python2.7/dist-packages/django/core/mail/__init__.py", line 61, in send_mail
connection=connection).send()
File "/usr/local/lib/python2.7/dist-packages/django/core/mail/message.py", line 248, in send
return self.get_connection(fail_silently).send_messages([self])
File "/usr/local/lib/python2.7/dist-packages/django/core/mail/backends/smtp.py", line 85, in send_messages
new_conn_created = self.open()
File "/usr/local/lib/python2.7/dist-packages/django/core/mail/backends/smtp.py", line 51, in open
self.connection.starttls()
File "/usr/lib/python2.7/smtplib.py", line 635, in starttls
raise SMTPException("STARTTLS extension not supported by server.")
SMTPException: STARTTLS extension not supported by server.
我认为exim4的设置有问题。
那么我如何解决这个 tls 错误。
提前致谢。