Django html e-mail - django

Pracujem na projekte, kde je potrebné poslať html email. Adresa URL musí vložiť obsah html

<p><a href="http://dealerfunnel.com/passwordchange">Password Change Link</a></p>

Môj názov domény, dealerfunnel.com, Ak uvediem platnú adresu URL okrem http://dealerfunnel.com potom sa odosiela e-mail. Ako keby som dal

google.com

potom sa odosiela e-mail. Ale keď som dal dealerfunnel.com , e-mail sa neposiela a nedostáva žiadnu chybu.

Skontrolujte môj kód:

from dealerfunnel.funnel.view.base import *
from django.template.loader import get_template
from django.core.mail import EmailMessage
import sys

class debug():
def sendmail(self,request):
message = get_template("mail/forgot.html").render(Context({"name":"Khalid Hossain"}))
try:
msg = EmailMessage("Password Change",message, to=["khalidrashed@gmail.com"], from_email="support@domainname")
msg.content_subtype = "html"
msg.send()
return HttpResponse(message)
except :
e = sys.exc_info()[0]
return HttpResponse(e)

odpovede:

0 pre odpoveď č. 1

Tu je to, čo môžete urobiť

def send_notification_email(template, **kwargs):
subject = "Your subject here"
context = Your_Context
email = Your_Email
body = render_to_string(template, {"context":context})
return send_mail(subject, body, settings.EMAIL_HOST_USER, [email], fail_silently=True)

Toto je, ak volanie tejto funkcie z vášho pohľadu. Ak nie, môžete použiť šablónu explicitne v metóde send_mail.

Teraz vo vašej šablóne nemôžete písať čo chcete a pošta by mala byť odoslaná