1

我有一个使用烧瓶邮件发送电子邮件的烧瓶应用程序,使用相同的邮件设置,我可以成功地从我的 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

我已经用谷歌搜索了大约两个小时,但找不到解决方案。请问有什么帮助吗?谢谢!!

4

2 回答 2

1

我通过在安全组和机器上打开 SMTPS 的端口来解决这个问题:465。

于 2020-11-22T03:06:44.933 回答
1

我想到了。我 AWS SES 需要验证不同区域的电子邮件。我没有为我正在使用的新区域这样做。

于 2016-01-28T16:21:14.710 回答