Django 中的服务器不支持 STARTTLS 扩展

STARTTLS extension not supported by server in django

我正在使用 gmail 来执行此操作,而且我仍在开发中。它只是不断抛出这个错误。昨天它正在工作。有时它也会停止并显示此错误,但整个今天它都没有按预期工作

setting.py

EMAIL_BACKEND = "django.core.mail.backends.smtp.EmailBackend"

EMAIL_HOST = "smtp.gmail.com"

EMAIL_USE_TLS = True

EMAIL_PORT = 587

EMAIL_HOST_USER = "testemail@gmail.com"

EMAIL_HOST_PASSWORD = "mypassword"

views.py

def mail_letter(request):
    emails = NewsLetter.objects.all()
    df = read_frame(emails, fieldnames=['email'])
    mail_list = df['email'].values.tolist()
    print(mail_list)
    if request.method == "POST":
        form = MailMessageForm(request.POST)
        if form.is_valid:
            form.save()
            # Sending Messages
            title = form.cleaned_data.get('title')
            message = form.cleaned_data.get('message')
            send_mail(
                title,
                message,
                '',
                mail_list,
                fail_silently=False,
            )
            # Success Alert
            messages.success(request, f"Messages sent successfully")
            subscribed = True
            return redirect('elements:mail_letter')
    else:
        form = MailMessageForm()

后来通过连接到新网络解决了这个问题,我的网络连接不好