Getting SSL error when sending mail via Django
[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:997)
This is what I see when I send mail via Django.
This is my email configuration in settings.py
# Email Settings
EMAIL_BACKEND = "django.core.mail.backends.smtp.EmailBackend"
EMAIL_HOST = "smtp.gmail.com"
EMAIL_PORT = 587
EMAIL_HOST_USER = "xxxxxxxx@gmail.com"
EMAIL_HOST_PASSWORD = "xxxxxxxxxxxxx"
EMAIL_USE_TLS = True
this is how I send mail
send_mail(
"Subject",
"Test message",
settings.EMAIL_HOST_USER,
["xxxxxxxxx@gmail.com"],
fail_silently=False,
)
This error message is indicating that there is a problem with the SSL certificate being used to send the email. One possible cause of this error is that the certificate being used is not from a trusted issuer, or that it is out of date. To fix this issue, you may need to update your certificate or configure your application to use a different certificate. Additionally, make sure that the sending email address is allowed to access less secure apps.
also you can send email by doing this
from django.core.mail import EmailMultiAlternatives
subject, from_email, to = emailSubject, '<your_gmail@gmail.com>', ["where you
want to send"]
msg = EmailMultiAlternatives(subject, from_email, to)
msg.send()