发送邮件时django中的错误号为10061

时间:2015-06-03 18:28:42

标签: python html django gmail sendmail

我已经使用10061服务器了。我的代码就像,

setting.py:

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

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.')

没有防火墙我应该配置哪个设置?是否需要定义端口?如果是,那么我应该在哪里定义?

1 个答案:

答案 0 :(得分:0)

settings.py文件中,您是否还要定义EMAIL_HOSTEMAIL_PORT等内容?

See the Django documentation了解您可以使用的各种设置。