Django send_mail没有使用gmail

时间:2015-05-27 19:35:27

标签: django email smtp gmail

我一直在努力让django发送测试邮件,但没有成功。我的测试电子邮件是从任何开发站点的python发送的。这是我的观点ajax:

def ajaxLearning(request): 
    if request.method == 'GET':
        from django.core.mail import send_mail
        send_mail('Put your Email subject here', 'Put your Email message here.',
                  'myspamgoes@gmail.com', ['someemail@yahoo.com'],
                  fail_silently=False)
        return HttpResponse("end");
     else:
        pass

这是我的settings.py:

DEFAULT_FROM_EMAIL = 'myspamgoes@gmail.com'
SERVER_EMAIL = 'myspamgoes@gmail.com'
EMAIL_USE_TLS = True
EMAIL_HOST = 'smtp.gmail.com'
EMAIL_PORT = 587
EMAIL_HOST_USER = 'myspamgoes@gmail.com'
EMAIL_HOST_PASSWORD = 'mypassword'

此时我觉得好像我犯了一些更高级别的错误,比如使用错误版本的django,无法安装重要的东西,或者在gmail端做错了什么。对于我今天早些时候更改过的密码,我使用的是我通常用来登录帐户的密码。感谢您抽出宝贵时间阅读我的问题!

1 个答案:

答案 0 :(得分:0)

更改settings.py

$.each(filterNodeData.FilterData, function (i, item) {
     var newData = filterNodeData.FilterData[i],
         value=newData.value,
         key = newData.key;
     trHTML += '<tr><td>' + '<select class="form-control">'+
             '<option value="and" '+(key=='and'?'selected':'')+'>And</option>'+
             '<option value="or" '+(key=='or'?'selected':'')+'>Or</option>'+
         '</select></td>' +
          '<td>' + '<input class="form-control" size=35 type="text" id="filterValue" value= ' + value + '>' + '</td>' +
          '<td><input type="button" id="delFilter" class="delHeader btn btn-md red" value="Delete" onclick="deleteFilter(this)" ></td>' +
          '<td><input type="button" id="AddFilter" class="btn btn-md btn-primary" value="Add" onclick="insertFilter()" ></td>' + '</tr>';
});
$('#filterTable').append(trHTML);