Reputation: 417
I have a flask app using flask-mail to send out emails, using the same mail setting, I can successfully send out emails locally from my MacBook Pro. But when I deploy the same code with same email setting on EC2 on Ubuntu14.04, I cannot send emails and got the following error:
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
I have googled this for about two hours and could not find a solution. Any help, please? Thanks!!
Upvotes: 1
Views: 1135
Reputation: 182
I solved this by opening port for SMTPS : 465 both on security group and the machine.
Upvotes: 2
Reputation: 417
I figured it out. I AWS SES needs to verify the email for different region. I did not do that for the new region I am using.
Upvotes: 1