I use a Django / Sendgrid / Heroku setup which was working well but it stopped with no apparent reason.
my django settings:
EMAIL_HOST="smtp.sendgrid.net"
EMAIL_HOST_PASSWORD="..."
EMAIL_HOST_USER="..."
EMAIL_PORT=587
EMAIL_USE_TLS=True
with this settings, if I send simple emails with the django library...
from django.core.mail import send_mail
send_mail(
'Subject here',
'Here is the message.',
from_email_address,
[to_email_address],
fail_silently=False,
)
I get this error
--> SMTPServerDisconnected: Connection unexpectedly closed
I can still send emails using the sendgrid python library
import sendgrid
sg = sendgrid.SendGridAPIClient(apikey)
sg.send(data)
Is there anything I am missing?
Just figured this out:
Sendgrid dynamically provides a password through the SENDGRID_PASSWORD
Heroku environment variable. However the variable used for the email settings is EMAIL_HOST_PASSWORD
which was not updated after our password changed.
Be sure that both variables are identical