简体   繁体   English

发送邮件时在Django中出现错误号10061

[英]error no 10061 in django when sending mail

I already use 10061 server. 我已经使用10061服务器。 My code is like, 我的代码就像

setting.py: setting.py:

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

views.py: views.py:

def trying(request):
    message = request.POST.get('message', '')

    if  message:
        try:
            send_mail("Testing", message, "s.tanna1992@gmail.com",['s.tanna1992@gmail.com'])
        except BadHeaderError:
            return HttpResponse('Invalid header found.')
        return HttpResponse('Send Successfully...1')
    else:
        # In reality we'd use a form class
        # to get proper validation errors.
        return HttpResponse('Make sure all fields are entered and valid.')

Which setting should I configure without firewall? 我应该在没有防火墙的情况下配置哪个设置? Is it neccessary to define port? 是否需要定义端口? If it is, then where should I define? 如果是,那我应该在哪里定义?

In your settings.py file, are you also defining things like EMAIL_HOST , EMAIL_PORT , etc? 您还可以在settings.py文件中定义EMAIL_HOSTEMAIL_PORT等内容吗?

See the Django documentation for the various settings you can use. 有关可用的各种设置, 请参见Django文档

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM