我有一个正在开发的小博客。在用户仅使用电子邮件注册后,我想发送一封电子邮件,其中包含指向密码重置页面的链接。
def email_signUp(request):
if request.method == 'POST':
if 'email_subscription' in request.POST:
form = EmailForm(request.POST)
if form.is_valid():
username = form.cleaned_data['email'].split('@')[0]
email = form.cleaned_data['email']
password1 = passgen()
User.objects.create_user(username=username, email=email, password=password1)
如何发送电子邮件?我已经可以在 'password_reset/'
正在使用
if DEBUG:
EMAIL_BACKEND = 'django.core.mail.backends.console.EmailBackend'
答案 0 :(得分:0)
这是快速示例 ->
from django.core.mail import send_mail
send_mail(
'Subject here',
'Here is the message.', #after you will create user object you can send in message api url like localhost:8000/password_reset/
'from@example.com',
['to@example.com'],
fail_silently=False,
)