i handle password reset
-- when i write this code can not me send email
def send_mail(to, template, context):
html_content = render_to_string(f'accounts/emails/{template}.html', context)
text_content = render_to_string(f'accounts/emails/{template}.txt', context)
msg = EmailMultiAlternatives(context['subject'], text_content, settings.EMAIL_HOST_USER, [to])
msg.attach_alternative(html_content, 'text/html')
msg.send()
when i write like this
send me email how to achieve dynamically
def send_mail(to, template, context):
html_content = render_to_string(f'accounts/emails/{template}.html', context)
text_content = render_to_string(f'accounts/emails/{template}.txt', context)
msg = EmailMultiAlternatives(context['subject'], text_content, settings.EMAIL_HOST_USER, ['inayatullahk.khela@gmail.com'])
msg.attach_alternative(html_content, 'text/html')
msg.send()
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/ad856393-c348-405c-8126-6952dda54791%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
No comments:
Post a Comment