Ubuntu 14.04 EC2 上的 flask-mail SMTPServerDisconnected 错误
flask-mail SMTPServerDisconnected error on EC2 with Ubuntu 14.04
我有一个使用 flask-mail 发送电子邮件的 flask 应用程序,使用相同的邮件设置,我可以从我的 MacBook Pro 本地成功发送电子邮件。但是当我在 Ubuntu14.04 上的 EC2 上部署具有相同电子邮件设置的相同代码时,我无法发送电子邮件并收到以下错误:
send: 'ehlo flasks-app-server1.localdomain\r\n'
Exception in thread Thread-2:
Traceback (most recent call last):
File "/usr/lib/python2.7/threading.py", line 810, in __bootstrap_inner
self.run()
File "/usr/lib/python2.7/threading.py", line 763, in run
self.__target(*self.__args, **self.__kwargs)
File "/srv/www/flasky/app/email.py", line 9, in send_async_email
mail.send(msg)
File "/usr/local/lib/python2.7/dist-packages/flask_mail.py", line 415, in send
with self.connect() as connection:
File "/usr/local/lib/python2.7/dist-packages/flask_mail.py", line 123, in __enter__
self.host = self.configure_host()
File "/usr/local/lib/python2.7/dist-packages/flask_mail.py", line 142, in configure_host
host.starttls()
File "/usr/lib/python2.7/smtplib.py", line 642, in starttls
self.ehlo_or_helo_if_needed()
File "/usr/lib/python2.7/smtplib.py", line 542, in ehlo_or_helo_if_needed
if not (200 <= self.ehlo()[0] <= 299):
File "/usr/lib/python2.7/smtplib.py", line 413, in ehlo
self.putcmd(self.ehlo_msg, name or self.local_hostname)
File "/usr/lib/python2.7/smtplib.py", line 341, in putcmd
self.send(str)
File "/usr/lib/python2.7/smtplib.py", line 333, in send
raise SMTPServerDisconnected('please run connect() first')
SMTPServerDisconnected: please run connect() first
我用谷歌搜索了大约两个小时,但找不到解决方案。有什么帮助吗?谢谢!!
我想通了。我 AWS SES 需要验证不同区域的电子邮件。我没有为我正在使用的新区域这样做。
我通过在安全组和机器上为 SMTPS 打开端口解决了这个问题:465。
我有一个使用 flask-mail 发送电子邮件的 flask 应用程序,使用相同的邮件设置,我可以从我的 MacBook Pro 本地成功发送电子邮件。但是当我在 Ubuntu14.04 上的 EC2 上部署具有相同电子邮件设置的相同代码时,我无法发送电子邮件并收到以下错误:
send: 'ehlo flasks-app-server1.localdomain\r\n'
Exception in thread Thread-2:
Traceback (most recent call last):
File "/usr/lib/python2.7/threading.py", line 810, in __bootstrap_inner
self.run()
File "/usr/lib/python2.7/threading.py", line 763, in run
self.__target(*self.__args, **self.__kwargs)
File "/srv/www/flasky/app/email.py", line 9, in send_async_email
mail.send(msg)
File "/usr/local/lib/python2.7/dist-packages/flask_mail.py", line 415, in send
with self.connect() as connection:
File "/usr/local/lib/python2.7/dist-packages/flask_mail.py", line 123, in __enter__
self.host = self.configure_host()
File "/usr/local/lib/python2.7/dist-packages/flask_mail.py", line 142, in configure_host
host.starttls()
File "/usr/lib/python2.7/smtplib.py", line 642, in starttls
self.ehlo_or_helo_if_needed()
File "/usr/lib/python2.7/smtplib.py", line 542, in ehlo_or_helo_if_needed
if not (200 <= self.ehlo()[0] <= 299):
File "/usr/lib/python2.7/smtplib.py", line 413, in ehlo
self.putcmd(self.ehlo_msg, name or self.local_hostname)
File "/usr/lib/python2.7/smtplib.py", line 341, in putcmd
self.send(str)
File "/usr/lib/python2.7/smtplib.py", line 333, in send
raise SMTPServerDisconnected('please run connect() first')
SMTPServerDisconnected: please run connect() first
我用谷歌搜索了大约两个小时,但找不到解决方案。有什么帮助吗?谢谢!!
我想通了。我 AWS SES 需要验证不同区域的电子邮件。我没有为我正在使用的新区域这样做。
我通过在安全组和机器上为 SMTPS 打开端口解决了这个问题:465。