title: Sending email using email.mime.multipart in Python
body: <p>I'm trying to learn python from a book ("Hello! Python"). This code should, according to the book, send an email.  no luck so far.</p>
  
  <pre><code>import os
  
  from email.mime.multipart import MIMEMultipart
  from email.mime.text import MIMEText
  import smtplib
  
  def send_message(message):
      s = smtplib.SMTP('smtp.me.com')
      s.sendmail(message['From'], message['To'], message.as_string())
      s.quit()
  
  def mail_report(to, ticker_name):
      outer = MIMEMultipart()
      outer['Subject'] = "Stock report for " + ticker_name
      outer['From'] = "myemail@mac.com"
      outer['To'] = to
  
      # Internal text container
      inner = MIMEMultipart('alternative')
      text = "Here is the stock report for " + ticker_name
      html = """\
      &lt;html&gt;
        &lt;head&gt;&lt;/head&gt;
        &lt;body&gt;
          &lt;p&gt;Here is teh stock report for
            &lt;b&gt; """ + ticker_name + """ &lt;/b&gt;
          &lt;/p&gt;
        &lt;/body&gt;
      &lt;/html&gt;
      """
      part1 = MIMEText(text, 'plain')
      part2 = MIMEText(html, 'html')
      inner.attach(part1)
      inner.attach(part2)
      outer.attach(inner)
  
      filename = 'stocktracker-%s.csv' % ticker_name
      csv_text = ''.join(file(filename).readlines())
      csv_part = MIMEText(csv_text, 'csv')
      csv_part.add_header('Content-Disposition', 'attachment', filename=filename), outer.attach(csv_part)
      return outer
  
  if __name__ == '__main__':
      email = mail_report('myemail@mac.com', 'GOOG')
      send_message(email)
  </code></pre>
  
  <p>I don't get an error, but I also don't get an email.  (needless to say, i'm using my actual email, not 'myemail@mac.com')  All suggestions and suggested reading appreciated.</p>