我跟着 The Django Book 到了第 7 章。当我尝试联系的例子时,我遇到了这个邮件发送错误。
有谁知道如何解决这一问题?
这是错误信息:
/contact/ 出现错误
[Errno 10061]
请求方法:POST
Request URL: http://127.0.0.1:8000/contact/<br>
Django 版本:1.5
异常类型:错误
异常值:[Errno 10061]
异常位置:C:\Python27\lib\socket.py in create_connection,第 571 行
Python 可执行文件:C:\Python27\python.exe
Python 版本:2.7.2
Python 路径:
['D:\Workspace\DJhello',
'D:\Workspace\DJhello',
'D:\Workspace\DJhello\src',
'C:\Python27\DLLs',
'C:\Python27\lib' ,
'C:\Python27\lib\plat-win',
'C:\Python27\lib\lib-tk',
'C:\Python27',
'C:\Python27\lib\site-packages',
'C: \Python27\lib\site-packages\win32',
'C:\Python27\lib\site-packages\win32\lib',
'C:\Python27\lib\site-packages\Pythonwin',
'C:\Python27\lib\site-packages\setuptools-0.6c11-py2.7.egg-info',
'C:\Windows\system32\python27.zip']
服务器时间: Thu, 14 Mar 2013 12:08 :14 +0800enter code here
这是我的代码:
def contact(request):
errors = []
if request.method == 'POST':
if not request.POST.get('subject', ''):
errors.append('Enter a subject.')
if not request.POST.get('message', ''):
errors.append('Enter a message.')
if request.POST.get('email') and '@' not in request.POST['email']:
errors.append('Enter a valid e-mail address.')
if not errors:
send_mail(
request.POST['subject'],
request.POST['message'],
request.POST.get('email', 'noreply@example.com'),
['siteowner@example.com'],
)
return HttpResponseRedirect('/contact/thanks/')
return render_to_response('contact_form.html',
{'errors': errors,
'subject': request.POST.get('subject', ''),
'message': request.POST.get('message', ''),
'email': request.POST.get('email', '')},
context_instance=RequestContext(request))