How to include newline in email message using send_mail and django?

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?



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
    render_to_string('core/emails/email.txt', context),

yes "%0A" for a new line it works well.

Need Your Help

Looking for layout xml files for the project

xml file layout location basic4android

I have saved several layout files with the designer but tried to look at them in Notepad and found they were not xml files.

Storing one or several sql statements as a variable in a stored procedure in SQL Server

sql sql-server stored-procedures

Let's say I have a stored procedure. Is it possible to store multiple sql statements in a variable inside a stored procedure and later execute it when the procedure is invoked?