0
我必須通過從Django中發送我的電子郵件一個問題:Django的send_mail [錯誤111]拒絕連接
Django Version: 1.11.3
Exception Type: error
Exception Value:
[Errno 111] Connection refused
Exception Location: /usr/lib/python2.7/socket.py in create_connection, line 571
Python Version: 2.7.6
settings.py
EMAIL_USE_TLS = True
EMAIL_HOST = 'smtp.gmail.com'
EMAIL_HOST_USER = '[email protected]'
EMAIL_HOST_PASSWORD = '******'
EMAIL_PORT = 587
views.py
...
from django.core.mail import send_mail
...
def testmail(request):
send_mail('subj2', 'message', '[email protected]', ['[email protected]'])
return HttpResponse('ok')
但,當我嘗試從控制檯發送消息時:
python manage.py shell
from django.core.mail import send_mail
send_mail('subj2', 'message', '[email protected]', ['[email protected]'])
它的工作,我sucessfuly收到我的消息。
檢查你的防火牆 – eyllanesc