Skip to content
Advertisement

STARTTLS extension not supported by server in django

i am using gmail to do this, and i’m still at development. it just keeps throwing this error. yesterday it was working. sometimes it would also stop and show this error, but throughout today it haven’t been working as expected

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()

Advertisement

Answer

This was later fixed by connecting to a new network, my network connection was not good

User contributions licensed under: CC BY-SA
9 People found this is helpful
Advertisement