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