title: Python sendmail with text file content
body: <p>I want to send mail via python script, I need it to alert me about some missed files.</p>
  
  <p>scripy have to read log file(*.txt) and send content of this file into my mail, so I made it:</p>
  
  <pre><code>import smtplib, os
  from email.mime.text import MIMEText
  
  
  raport_file = open('alert.txt','rb')
  alert_msg = MIMEText(raport_file.read().encode("utf-8"), 'plain', 'utf-8')
  raport_file.close()
  
  
  
  
  m = smtplib.SMTP()
  m.connect("*****", 25)
  m.sendmail("Check_Files", "*****", alert_msg.as_string())
  m.quit()
  </code></pre>
  
  <p>script run, but there is no mail at all. If I replace alert_msg.as_string() with "any text", everything works fine.</p>