Search code examples
djangosendgriddjango-allauth

Django SendGrid + allauth


I am currently trying to implement SendGrid in order to send confirmation emails for social accounts users that register and I get the following error

SMTPDataError at /accounts/facebook/login/callback/
(550, b'The from address does not match a verified Sender Identity. Mail cannot be sent until this error is resolved. Visit https://sendgrid.com/docs/for-developers/sending-email/sender-identity/ to see the Sender Identity requirements')

I have already done Single Sender Verification on SendGrid so everything should be fine on that end however I have contacted SendGrid too just in case. Below are my settings in case I might have missed something?

EMAIL_PORT = 587
EMAIL_USE_TLS = True
EMAIL_HOST_USER = 'apikey' # this is exactly the value 'apikey'
EMAIL_HOST_PASSWORD = config('SENDGRID_API_KEY')
EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend'

Any help is very much appreciated.


Solution

  • Came across this question facing this problem myself - turns out you need the below two settings, in addition to those above:

    EMAIL_HOST = 'smtp.sendgrid.net'
    # the email you verified with sendgrid (if you did single sender verification)
    DEFAULT_FROM_EMAIL = '[email protected]'