I am trying to send emails from my django app using the the gmail smtp servers. The emails are being sent when I run the application on my local server. But I'm getting an SMTP Authentication Error while using it on heroku.
Traceback - link
settings.py -
# Email configuration.
EMAIL_HOST = 'smtp.gmail.com'
EMAIL_PORT = 587
EMAIL_HOST_USER = '***************@gmail.com'
EMAIL_HOST_PASSWORD = '************'
EMAIL_USE_TLS = True
DEFAULT_FROM_EMAIL = '******************@gmail.com'
EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend'
And I have rechecked the account password, also I have enabled the access of less secure apps from my google account. But still I am getting this error.
Disabling CAPTCHA for clients
If you are not using 2-factor authentication and you have verified the credentials in your Python source are correct, follow these steps:
Click the continue button, and you will see the message
Account access enabled Please try signing in to your Google account again from your new device or application.
Run your Python script - your login attempt should be successful.
Try using sendgrid, because gmail smtp has some problem. I too was unable to do using gmail smtp. But it worked perfectly using sendgrid. And this is also free for basic use.
EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend'
EMAIL_HOST = 'smtp.sendgrid.net'
EMAIL_HOST_USER = 'username'
EMAIL_HOST_PASSWORD = 'userpassword'
EMAIL_PORT = 587
EMAIL_USE_TLS = True
DEFAULT_FROM_EMAIL = '[email protected]'
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With