2
votes

I'm attempting to get a django site up and running and I'm trying to enable django's standard password reset service.

My site is hosted by AWS EC2, so I figured I would use AWS SES for my email service. However, I can't get the smtp connection to work. Any idea on how to solve for the following error:

Exception Type: SMTPSenderRefused Exception Value: (530, b'Authentication required', '[email protected]')

I've looked at the following, but I'd prefer to stay with django's built-in email back-ends if possible:

Email Settings:

EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend'
EMAIL_HOST = 'email-smtp.us-west-2.amazonaws.com'
EMAIL_PORT = 587 # (I've also tried 25, 465, & 2587)
EMAIL_HOST_USER = ''
EMAIL_PASSWORD = ''
EMAIL_USE_TLS = True
DEFAULT_FROM_EMAIL = '[email protected]' # but my real email address

My EMAIL_HOST_USER and EMAIL_PASSWORD are set to my SMTP credentials I obtained by following the instructions at: https://docs.aws.amazon.com/ses/latest/DeveloperGuide/smtp-credentials.html

Also, I was sure to verify my DEFAULT_FROM_EMAIL and my domain following these instructions: https://docs.aws.amazon.com/ses/latest/DeveloperGuide/verify-addresses-and-domains.html

And DKIM is enabled and my nameservers have been updated.

Any help would really be appreciated.

UPDATE:

I was able to get the django email send working with the django-ses 3rd party library, but I'm still not able to figure out why the standard backend doesn't work via SMTP.

I think there is definitely something wrong with my code as I went so far as to switch email clients from AWS SES to Zoho mail and I'm still receiving the same 530 Authentication required error.

EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend'
EMAIL_HOST = 'smtp.zoho.com'
EMAIL_PORT = 587
EMAIL_HOST_USER = '[email protected]'
EMAIL_USE_TLS = True
DEFAULT_FROM_EMAIL = '[email protected]'
EMAIL_PASSWORD = ''
2

2 Answers

2
votes

2021: Django-3.2.4

No libraries needed such as django-ses or django-amazon-ses !!

EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend'
EMAIL_HOST = 'email-smtp.us-west-2.amazonaws.com'
EMAIL_PORT = 587
EMAIL_USE_TLS = True
EMAIL_HOST_USER = 'my_smtp_username'      # Must create SMTP Credentials
EMAIL_HOST_PASSWORD = 'my_smtp_password'  # Must create SMTP Credentials
DEFAULT_FROM_EMAIL = '[email protected]'

For EMAIL_HOST, choose SMTP Settings:

enter image description here


Then, put Server Name to EMAIL_HOST.

enter image description here


EMAIL_HOST = 'email-smtp.us-west-2.amazonaws.com'

For EMAIL_HOST_USER and EMAIL_HOST_PASSWORD, you must create SMTP Credentials.

Press Create My SMTP Credentials Button:

enter image description here


Given SMTP Credentials:

enter image description here


Then, put the SMTP Credentials as below:

EMAIL_HOST_USER = 'AKIAWP3TMGZN4OZH5H37'
EMAIL_HOST_PASSWORD = 'BB6dufiw96jJHUTrowXI8R4gcyOI+t1+Skbi51cdHYhV'

*(I've already deleted these SMTP Credentials)


Moreover, for DEFAULT_FROM_EMAIL, put one verified domain or email address whether or not your account is in the sandbox.

So for the varified domain sender.com below,

enter image description here


Three of them below are valid: (Use only one of three)

DEFAULT_FROM_EMAIL = '[email protected]' # OR
DEFAULT_FROM_EMAIL = '[email protected]' # OR
DEFAULT_FROM_EMAIL = '[email protected]'

But these two below are not valid: (These give you error)

*The format must be [email protected] !!

DEFAULT_FROM_EMAIL = 'sender.com' 
DEFAULT_FROM_EMAIL = '@sender.com'

Then, for the varified 2 email addresses below,

enter image description here


Just use only one of two below:

DEFAULT_FROM_EMAIL = '[email protected]' # OR
DEFAULT_FROM_EMAIL = '[email protected]'
0
votes

If it is asking for Authentication, please double-check the following:

  • Your SMTP settings
  • The email that you're trying to send mails from belongs to the verified domain. e.g. if you have verified example.com but you try sending emails from [email protected], it is going to ask for gmail auth credentials.