Django Ошибка Errno 11001 getaddrinfo failed

Пытаюсь отправить электронное письмо с помощью smtp на gmail, но получаю "error 11001 getaddrinfo failed". Я не уверен, что делаю неправильно.

Вот мой 'settings.py'

EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend'
EMAIL_USE_SSL = True
EMAIL_HOST = 'smtp.gmail.com'
EMAIL_HOST_USER = '******@gmail.com' 
EMAIL_HOST_PASSWORD = '********'
EMAIL_PORT = 465 

функция почты:

def send_notification(dataframe):
    subject = 'That’s your subject'
    from_email = settings.EMAIL_HOST_USER 
    to = '*******@gmail.com'
    text_content = 'That’s your plain text.'
    html_content = """\
            <html>
              <head></head>
              <body>
                <p> Test email from django </p>
              </body>
            </html>
        """
    message = EmailMultiAlternatives(subject, text_content, from_email, [to])
    message.attach_alternative(html_content, "text/html")
    message.send()

Ошибка:

for res in _socket.getaddrinfo(host, port, family, type, proto, flags):
socket.gaierror: [Errno 11001] getaddrinfo failed
[26/Jul/2022 13:21:51] "GET / HTTP/1.1" 500 114527
Вернуться на верх