Django 使用google smtp[Errno 11001]getaddrinfo的djnago失败

Django 使用google smtp[Errno 11001]getaddrinfo的djnago失败,django,smtp,Django,Smtp,在my settings.py中 EMAIL_HOST = 'smtp.google.com' EMAIL_PORT = 465 EMAIL_HOST_USER = '*********@gmail.com' EMAIL_HOST_PASSWORD = '************' EMAIL_USE_SSL = True in views.py def sendEmail(request, order_id): order = Inventory_Order.objects.get(

在my settings.py中

EMAIL_HOST = 'smtp.google.com'
EMAIL_PORT = 465
EMAIL_HOST_USER = '*********@gmail.com'
EMAIL_HOST_PASSWORD = '************'
EMAIL_USE_SSL = True
in views.py

def sendEmail(request, order_id):
    order = Inventory_Order.objects.get(id=order_id)
    orderitems = Order_Item.objects.filter(order=order)

    try:
        subject = f"Wiss - New Order {order}"
        to = [f'{order.customer.email}']
        from_email = settings.EMAIL_HOST_USER
        order_information = {
            'order':order,
            'orderitems':orderitems
        }
        message = get_template('Inventory_Management/email.html').render(order_information)
        msg = EmailMessage(subject, message, to=to, from_email=from_email)
        msg.content_subtype = 'html'
        msg.send(fail_silently=False)
        print(f'message sent to {order.customer.email}!')
    except IOError as e:
        print('Failed')
        print(e)
        return e

调用函数时,出现以下错误[Errno 11001]getaddrinfo失败,问题是什么?非常感谢您的帮助……

它确实不起作用,然后我发现它应该是smtp.googlemail.com而不是smtp.google.com,这让我非常惊讶,因为我第一次使用的网站是smtp.google.com。不管怎样,它现在起作用了

使用
smtp.gmail.com
作为
电子邮件主机

发件人:

步骤2:更改电子邮件客户端中的SMTP和其他设置

发送邮件(SMTP)服务器>SMTP.gmail.com

还提到了其他必要的设置