'I'm unable to send emails from Django App on AWS
I'm unable to receive emails from my app after deploying to Aws, My app sits on Ec2 and I host my env on Elastic Bean, The emailing situation works fine locally but not on AWS. Note: I use Amazon SES
I'm not sure on what to do next at this point, I don't seem to be able to find the problem.
HERE IS MY SETTINGS FOR EMAIL
EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend'
EMAIL_HOST = os.getenv('EMAIL_HOST')
EMAIL_PORT = 587
EMAIL_USE_TLS = True
# EMAIL_USE_SSL=True
EMAIL_HOST_USER = os.getenv('EMAIL_HOST_USER')
EMAIL_HOST_PASSWORD = os.getenv('EMAIL_HOST_PASSWORD')
HERE IS MY LOG FILE
django_1 | Exception in thread Thread-184:
django_1 | Traceback (most recent call last):
django_1 | File "/usr/local/lib/python3.9/threading.py", line 973, in _bootstrap_inner
django_1 | self.run()
django_1 | File "/build/authentication/utils.py", line 15, in run
django_1 | self.email.send()
django_1 | File "/usr/local/lib/python3.9/site-packages/django/core/mail/message.py", line 284, in send
django_1 | return self.get_connection(fail_silently).send_messages([self])
django_1 | File "/usr/local/lib/python3.9/site-packages/django/core/mail/backends/smtp.py", line 102, in send_messages
django_1 | new_conn_created = self.open()
django_1 | File "/usr/local/lib/python3.9/site-packages/django/core/mail/backends/smtp.py", line 67, in open
django_1 | self.connection.starttls(keyfile=self.ssl_keyfile, certfile=self.ssl_certfile)
django_1 | File "/usr/local/lib/python3.9/smtplib.py", line 769, in starttls
django_1 | self.ehlo_or_helo_if_needed()
django_1 | File "/usr/local/lib/python3.9/smtplib.py", line 611, in ehlo_or_helo_if_needed
django_1 | if not (200 <= self.ehlo()[0] <= 299):
django_1 | File "/usr/local/lib/python3.9/smtplib.py", line 451, in ehlo
django_1 | self.putcmd(self.ehlo_msg, name or self.local_hostname)
django_1 | File "/usr/local/lib/python3.9/smtplib.py", line 378, in putcmd
django_1 | self.send(f'{s}{CRLF}')
django_1 | File "/usr/local/lib/python3.9/smtplib.py", line 365, in send
django_1 | raise SMTPServerDisconnected('please run connect() first')
django_1 | smtplib.SMTPServerDisconnected: please run connect() first
django_1 | [23/Mar/2022 11:29:11] "POST /api/auth/register HTTP/1.1" 201 1246```
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
