简体   繁体   English

django电子邮件未发送:ConnectionRefusedError WinError 10061

[英]django email not being sent : ConnectionRefusedError WinError 10061

I am writing django application and trying to send email using it I have "Access to low security app" in gmail enabled and django setting are given below which I think are right. 我正在编写django应用程序,并尝试使用它发送电子邮件,我在启用了gmail的情况下启用了“访问低安全性应用程序”,并且在下面给出了django设置,我认为这是正确的。 but I am still getting error as mentioned it title. 但我仍然收到标题中提到的错误。 I dont know the problem but I know I am not getting logged in to send email. 我不知道问题所在,但我知道我没有登录才能发送电子邮件。 Edit 1: I have made two changes first in settings.py and second in views.py in views.py I replaced email entered by user to mine(syedfaizan824@gmail.com) and settings.py DEFAULT_EMAIL_FROM is changed form testing@example.com to syedfaizan824@gmail.com 编辑1:我在settings.py中进行了两次更改,然后在views.py中的views.py中进行了第二次更改,我将用户输入的电子邮件替换为我的电子邮件(syedfaizan824@gmail.com),而settings.py DEFAULT_EMAIL_FROM更改为testing @ example。 com到syedfaizan824@gmail.com

searched on internet and find out that gmail does not allow low security app to login by default but I turned it off in setting of gmail. 在互联网上进行搜索,发现默认情况下gmail不允许低安全性应用登录,但我在gmail设置中将其关闭。 find out that my email backend was wrong so made it right. 找出我的电子邮件后端是错误的,因此正确。 fail silently is False. 默默地失败是错误的。

settings.py settings.py

EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend'
EMAL_HOST = 'smtp.gmail.com'
EMAIL_USE_TLS = True
EMAIL_PORT = 587
DEFAULT_FROM_EMAIL = 'syedfaizan824@gmail.com'
EMAIL_HOST_USER = 'syedfaizan824@gmail.com'
EMAIL_HOST_PASSWORD = '******'

views.py views.py

def post(self, request, *args, **kwargs):
    form = contact(request.POST)
    if form.is_valid():
        name = form.cleaned_data['name']
        email = form.cleaned_data['email']
        phone = form.cleaned_data['phone']
        organization = form.cleaned_data['organization']
        message = form.cleaned_data['message']
        ref_code = form.cleaned_data['ref_code']
        plan = form.cleaned_data['plan']
        message = message + ref_code 
        send_mail(
            'from website' + name + " " + organization,
             message,
            'syedfaizan824@gmail.com',
            ['syedfaizan824@gmail.com'],
            fail_silently=False,
        )
        print("sent")

    else:
        #print('something is wrong with forms!')
    return render(request, self.template_name, self.context)

Error message is ConnectionRefusedError WinError[10061]. 错误消息是ConnectionRefusedError WinError [10061]。 and statement of error is : No connection could be made because the target machine actively refused it. 错误声明是:由于目标计算机主动拒绝连接,因此无法建立连接。 which means I am not getting logged in. 这表示我没有登录。

change EMAL_HOST = 'smtp.gmail.com' to EMAIL_HOST = 'smtp.gmail.com' EMAL_HOST = 'smtp.gmail.com'更改为EMAIL_HOST = 'smtp.gmail.com'

You are missing the 'I' character in the word 'EMAIL' 您在“电子邮件”一词中缺少“我”字符

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Python ConnectionRefusedError:[WinError 10061] - Python ConnectionRefusedError: [WinError 10061] 当 ConnectionRefusedError: [WinError 10061] 时重试 - Retry when ConnectionRefusedError: [WinError 10061] selenium ConnectionRefusedError:python 3 中的 [WinError 10061] - selenium ConnectionRefusedError: [WinError 10061] in python 3 Python 请求中的大量“ConnectionRefusedError:[WinError 10061]” - Numerous "ConnectionRefusedError: [WinError 10061]" in Python requests Python套接字编程-ConnectionRefusedError:[WinError 10061] - Python Socket Programming - ConnectionRefusedError: [WinError 10061] Python socket问题-ConnectionRefusedError: [WinError 10061] - Python socket problem-ConnectionRefusedError: [WinError 10061] 如何修复 ConnectionRefusedError: [WinError 10061] 目标机器主动拒绝它? (Django 电子邮件) - How to fix ConnectionRefusedError: [WinError 10061] the target machine actively refused it? (Django e.mails) ConnectionRefusedError: [WinError 10061] 目标机主动拒绝如何解决? (Django SMTP) - How to solve the ConnectionRefusedError: [WinError 10061] the target machine actively refused it? (Django SMTP) python连接到mySql error-ConnectionRefusedError:[WinError 10061] - python connect to mySql error-ConnectionRefusedError: [WinError 10061] ConnectionRefusedError: [WinError 10061][WinError 10061] 由于目标机器主动拒绝,无法建立连接 - ConnectionRefusedError: [WinError 10061][WinError 10061] No connection could be made because the target machine actively refused it
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM