Django Sending Email : SMTPServerDisconnected: Connection unexpectedly closed

后端 未结 6 1731

hello i want to sending email activation use django registration redux.

this is my setting.py

EMAIL_BACKEND = \'django.core.mail.backends.smtp.EmailBackend         


        
6条回答
  •  暖寄归人
    2021-02-13 02:59

    For python3.0+

    I found a workaround or maybe this is the solution , there is some issue in the django email package.

    1)pip install sendgrid-django

    2)Add these in the settings.py along with other email configurations

      EMAIL_BACKEND = 'sgbackend.SendGridBackend'
      SENDGRID_API_KEY = "YOUR SENDGRID API KEY"
      EMAIL_PORT = 465
    

    3)Code sample to send mail(yours maybe different):

    from django.core.mail import EmailMessage
    send_email = EmailMessage(
        subject=subject,
        body=body,
        from_email=from_email,
        to=to_email,
        reply_to=reply_to,
        headers=headers,
    
    )
    send_email.send(fail_silently=fail_silently)
    

    You have to certainly make changes to the code as i was just showing a example.

    For debugging purpose only-sendgrid mail send using telnet

提交回复
热议问题