Issue
I would like to send email message with newlines. Let say, by following code:
send_mail("subject", "Hi George\n Thanks for registration", "from", "to")
I expect:
Hi George
Thanks for registration
Whereas that what I get is: Hi George\n Thanks for registration
Email is send to a gmail account if that matters.
Any ideas?
Thanks!
Solution
The best way you can accomplish that is by puting the mail text in template and use django template loader to render it with context.
from django.template.loader import render_to_string
context = {} # Fill it with your context
send_mail(
'Subject',
render_to_string('core/emails/email.txt', context),
'[email protected]',
['[email protected]'],
fail_silently=False)
Answered By - Vladislav Mitov
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.