我启动了一个新的应用程序gmail并在中配置了设置设置.py用我的gmail帐户
我刚到django,不知道如何给我的网站用户发送电子邮件
我想创建一个链接,当我打开它,我的用户将得到一个消息从我
我编辑过视图.py但我不知道我的函数“wyslij”应该返回什么
from django.shortcuts import render
from django.core.mail import send_mail
from django.contrib.auth.decorators import user_passes_test
from django.contrib.auth.models import User
from userprofile.models import UserProfile
@user_passes_test(lambda u: u.is_superuser)
# Create your views here.
def wyslij(request):
# Create the HttpResponse object with the appropriate PDF headers.
uzyt = UserProfile.objects.all().order_by('user_id')
for z, uzyt in enumerate(UserProfile.objects.all()):
send_mail('The exam is comming', 'Hi, Your exam will be tomorrow!', 'santa.claus.for.grace@gmail.com', [uzyt.email], fail_silently=False)
return response
在网址.py你知道吗
from django.conf.urls.defaults import patterns, include, url
urlpatterns = patterns('',
url(r'^accounts/wyslij/$', 'gmail.views.wyslij'),
)
https://docs.djangoproject.com/en/1.7/topics/email/
一定要命名你的电子邮件变量和.git忽略你的设置文件
在设置.py,您必须添加这些内衬:
相关问题 更多 >
编程相关推荐