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!
Newline code \n (LF), \r\n (CR + LF) Inserting a newline code \n , \r\n into a string will result in a line break at that location. On Unix, including Mac, \n (LF) is often used, and on Windows, \r\n (CR + LF) is often used as a newline code. Some text editors allow you to select a newline code.
How to send multiple mass emails django. We need to create a Tuple of messages and send them using send mass mail. In this tutorial, we create a project which sends email using Django. We fill the data in the form and send it using Django Email.
{{ text|escape|linebreaks }} is a common idiom for escaping text contents, then converting line breaks to <p> tags.
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)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With