django 发送邮件 连接失败

m不器 2016-09-12 07:50:19
我的126邮箱smtp服务开了,密码是我的登录密码,就是无法发送,求大神指教


STATIC_URL = '/static/'

EMAIL_POST = 'smtp.126.com'
EMAIL_PORT = 25
EMAIL_HOST_USER = 'mxbuqi@126.com'
EMAIL_HOST_PASSWORD = ' 密码'
EMAIL_SUBJECT_PREFTX = u''
EMAIL_USE_TLS = True

SERVER_EMAIL = '2229009552@qq.com'



def contact(request):
error = []
if request.method == 'POST':
if not request.POST.get('subject', ''):
error.append("please enter a subject")
if not request.POST.get('message',''):
error.append("please enter a message")
if request.POST.get('email') and "@" not in request.POST["email"]:
error.append("Please enter a valid e-mail")
if not error:
# send_mail(request.POST['subject'], request.POST['message'], request.POST.get('email', 'mxbuqi@126.com'), ['2229009552@qq.com'], fail_silently=True)
send_mail('subject', 'this is the message of email', 'mxbuqi@126.com', ['2229009552@qq.com'], fail_silently=True)
return HttpResponseRedirect('/contact/thanks/')
return render_to_response('contact.html', {'error' : error})

报的错误

error at /contact/
[Errno 10061]
Request Method: POST
Request URL: http://127.0.0.1:8000/contact/
Django Version: 1.10
Exception Type: error
Exception Value:
[Errno 10061]
Exception Location: D:\Python\lib\socket.py in create_connection, line 571
Python Executable: D:\Python\python.exe
Python Version: 2.7.3
Python Path:
['C:\\Users\\miaoxu\\mysite',
'D:\\Python\\lib\\site-packages\\django-1.10-py2.7.egg',
'D:\\Python\\python27.zip',
'D:\\Python\\DLLs',
'D:\\Python\\lib',
'D:\\Python\\lib\\plat-win',
'D:\\Python\\lib\\lib-tk',
'D:\\Python',
'D:\\Python\\lib\\site-packages',
'D:\\Python\\lib\\site-packages\\PIL',
'D:\\Python\\lib\\site-packages\\win32',
'D:\\Python\\lib\\site-packages\\win32\\lib',
'D:\\Python\\lib\\site-packages\\Pythonwin']
Server time: 星期日, 11 九月 2016 23:35:09 +0000
...全文
186 1 打赏 收藏 转发到动态 举报
写回复
用AI写文章
1 条回复
切换为时间正序
请发表友善的回复…
发表回复
hijack00 2016-09-12
  • 打赏
  • 举报
回复
你现在是想通过本地邮件服务器往126邮箱发邮件还是通过126邮箱给其他邮箱发邮件? 我怎么感觉你的Request URL应该是126邮箱smtp服务器的地址

37,718

社区成员

发帖
与我相关
我的任务
社区描述
JavaScript,VBScript,AngleScript,ActionScript,Shell,Perl,Ruby,Lua,Tcl,Scala,MaxScript 等脚本语言交流。
社区管理员
  • 脚本语言(Perl/Python)社区
  • IT.BOB
加入社区
  • 近7日
  • 近30日
  • 至今

试试用AI创作助手写篇文章吧