title: Django 1.7: how to send emails by using an html/css file as template
body: <p>From Django 1.7, it is possible to <code>send_email()</code> with a new parameter: <code>html_message</code>. Unfortunately, there is not a comprehensive guide (newby friendly) on how to use it (or at least I could not find it). </p>
  
  <p>I need to make sent emails nice and, thus, I'm trying to figure out how to include my message into a html/css template.
  I've read many posts about this subject, but most of them refer to previous version of Django. <a href="https://stackoverflow.com/questions/27122584/sending-email-with-html-in-django-1-7">This</a> post is for Django 1.7 but the answer shows the usage of a very basic html file. </p>
  
  <p><strong>my_html_message.html</strong></p>
  
  <pre><code>&lt;html lang="en"&gt;
   &lt;head&gt;
    &lt;link href="path/to/application.css" rel="stylesheet"&gt;
   &lt;/head&gt;
   &lt;body&gt;
    &lt;div class="email_header"&gt;
      [..]
      &lt;a href="http://mysite.it"&gt;&lt;img src="images/logo.png"/&gt;&lt;/a&gt;
    &lt;/div&gt;
    &lt;div class="email_body"&gt;
     [..]
     {{my_message}}
    &lt;/div&gt;
   &lt;/body&gt;
  </code></pre>
  
  <p><strong>my_message.txt</strong></p>
  
  <pre><code> Dear {{username}}, 
   you won {{money}}.
  </code></pre>
  
  <p><strong>my_function.py</strong></p>
  
  <pre><code>def my_send_email(request):
   subject = 'Test html email'
   from = 'my@email.com'
   to = 'yours@email.com'
   my_context = Context({'username': user.username,
               'money': user.money})
   html_message = render_to_string('mail/my_html_message.html', c)
   message = render_to_string('mail/my_message.txt', c)
   send_mail(subject,
            message,
            from,
            [to],
            html_message=html_message)
  </code></pre>
  
  <p>How can I pass to <code>my_html_message.html</code> the file <code>my_message.txt</code> with <code>my_context</code> and send an email with a custom style?</p>