title: How to send an email with style in Python3?
body: <p>I am sending emails from a Python3 script (using <code>smtplib</code>). By now, I am always receiving the messages in Gmail accounts. But the problem is I am not able to show CSS styles, in spite of being inline. Besides, even this simple message cannot be sent:</p>
  
  <pre><code>title = 'My title'
  msg_content = '&lt;h2&gt;{title}: &lt;font color="green"&gt;OK&lt;/font&gt;&lt;/h2&gt;\n'.format(title=title)
  </code></pre>
  
  <p>However, if I remove the two points just after {title}, it works. And if I remove the \n at the end it will not work again. Why? How can I send a line like this in Python3?</p>
  
  <pre><code>title = 'My title'
  msg_content = '&lt;h2&gt;{title}: &lt;span style="color: green"&gt;OK&lt;/span&gt;&lt;/h2&gt;'.format(title=title)
  </code></pre>
  
  <p><strong>EDIT</strong></p>
  
  <pre><code>import smtplib
  
  msg_header = 'From: Sender Name &lt;sender@server&gt;\n' \
               'To: Receiver Name &lt;receiver@server&gt;\n' \
               'Cc: Receiver2 Name &lt;receiver2@server&gt;\n' \
               'MIME-Version: 1.0\n' \
               'Content-type: text/html\n' \
               'Subject: Any subject\n'
  title = 'My title'
  msg_content = '&lt;h2&gt;{title} &gt; &lt;font color="green"&gt;OK&lt;/font&gt;&lt;/h2&gt;\n'.format(
      title=title)
  msg_full = (''.join([msg_header, msg_content])).encode()
  
  server = smtplib.SMTP('smtp.gmail.com:587')
  server.starttls()
  server.login('sender@server.com', 'senderpassword')
  server.sendmail('sender@server.com',
                  ['receiver@server.com', 'receiver@server.com'],
                  msg_full)
  server.quit()
  </code></pre>