我跟着Django書到第7章。當我嘗試聯繫的例子時,我遇到了這個郵件發送錯誤。Django郵件發送錯誤:[錯誤10061]
有誰知道如何解決這個問題?
以下是錯誤信息:在/接觸
錯誤/
[錯誤10061]
請求方法:POST
Request URL: http://127.0.0.1:8000/contact/<br>
Django的版本:1.5
異常類型:錯誤
異常值:[Errno 10061]
異常位置:C:\ Python27 \ lib \ socket.py in crea te_connection,線571
的Python可執行文件:C:\ Python27 \ python.exe
Python的版本:2.7.2
Python的路徑:
[ 'd:\工作區\ DJhello',
「d:\工作區\ DJhello '
'd:\工作區\ DJhello \ SRC',
'C:\ Python27 \的DLL',
'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 \站點包\ PythonWin的',
'C:\ Python27 \ LIB \站點包\ setuptools的-0.6c11-py2.7.egg-信息',
「C: \ Windows \ System32下\ python27.zip']
服務器時間:星期四,2013年3月14日12點08分14秒+0800 enter 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', '[email protected]'),
['[email protected]'],
)
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))
您的郵件服務器是否正在運行並等待r連接指定的IP和端口? – Rohan 2013-03-14 04:42:24
你在你的設置中有電子郵件配置嗎? – catherine 2013-03-14 04:43:42