title: How to add a dynamic content into html for sending mail in Python
body: <p>I am sending mail with html content using 'smtplib' in python , I want to add dynamic content to that html.</p>
  
  <pre><code>import smtplib
  from email.mime.text import MIMEText
  from email.mime.multipart import MIMEMultipart
  
  message = MIMEMultipart("alternative")
  message["Subject"] = "Error Notification"
  message["From"] = sender
  message["To"] = sender
  
  # Create the plain-text and HTML version of your message
  html = """\
      &lt;html&gt;
        &lt;body&gt;
          &lt;p&gt;Hi,&lt;br&gt;
             &lt;span&gt;Something went wrong !&lt;/span&gt;&lt;br&gt;
          &lt;/p&gt;
        &lt;/body&gt;
      &lt;/html&gt;
      """
  part1 = MIMEText(html, "html")
  
  # Add HTML/plain-text parts to MIMEMultipart message
  message.attach(part1)
  try:
      smtpObj = smtplib.SMTP('localhost')
      smtpObj.sendmail(sender, receivers, message.as_string())
      print "Successfully sent email"
  except smtplib.SMTPException:
      print "Error: unable to send email"
  </code></pre>
  
  <p>Along with the above html I need to include some of my dynamic contents inside the body tag</p>