Django mail_admins未发送电子邮件

时间:2019-03-06 04:06:13

标签: python django

我尝试使用send_mail并正常工作(它的html显示值“ 1”),但是当我访问localhost:8000 / emailAdmins时,它在html中显示“ none”一词,请帮助我为什么我的mail_admins不工作

我的设置

EMAIL_HOST='smtp.gmail.com'
EMAIL_HOST_USER='myemail@gmail.com'
EMAIL_HOST_PASSWORD='password'
EMAIL_PORT=587
EMAIL_USE_TLS=True

ADMINS = [
    ('myname' , 'myemail@gmail.com'),
]

我的网址

from django.conf.urls import url
from app1 import views as myapp

urlpatterns = [

     url(r'^emailAdmins/',myapp.sendAdminsEmail,name='emailAdmins'),
]

我的观点

from django.http import HttpResponse
from django.core.mail import mail_admins

def sendAdminsEmail(request):
    res = mail_admins('my subject', 'site is going down',)
    return HttpResponse('%s' %res)

0 个答案:

没有答案