【发布时间】:2017-03-20 03:11:59
【问题描述】:
我想将链接发送到电子邮件,因此当用户单击该链接时,用户将被重定向到推荐页面并可以推荐其他朋友。我使用 send_mail 发送电子邮件。除 html 消息外,所有内容都已发送。这是我所做的
if created:
new_join_old.invite_code = get_invite_code()
new_join_old.save()
subject = "Thank you for your request to sign up our community"
html_message = '<a href="http://localhost:8000/{% url "invitations:refer-invitation" invite_code %}">Click Here</a>'
message = "Welcome! We will be in contact with you."
from_email = None
to_email = [email]
send_mail(subject, message, from_email, to_email, fail_silently=True, html_message=html_message)
messages.success(request, '{0} has been invited'.format(email))
return HttpResponseRedirect("/invitations/refer-invitation/%s"%(new_join_old.invite_code))
context = {"form": form}
return render(request, 'home.html', context)
【问题讨论】:
-
如果您在本地以调试模式对其进行测试,您会在控制台中看到没有 HTML 部分的消息,对吧?
-
你试过这个吗:
html_message = '<a href="http://localhost:8000{}">Click Here</a>'.format(reverse('invitations:refer-invitation', kwrags={'invite_code': invite_code}))? -
你得到什么错误?
-
nup 它不工作。仍然只有 html 消息没有发送
标签: python django django-1.9