title: How to send email with pdf attachment in Python?
body: <blockquote>
    <p><strong>Possible Duplicate:</strong><br>
    <a href="https://stackoverflow.com/questions/3362600/how-to-send-email-attachments-with-python">How to send Email Attachments with python</a>  </p>
  </blockquote>
  
  
  
  <p>I would like to edit the following code and send an email with an attachment. Attachment is a pdf file, it is under /home/myuser/sample.pdf, in linux environment. What should I change below?</p>
  
  <pre><code>import smtplib  
  fromaddr = 'myemail@gmail.com'  
  toaddrs  = 'youremail@gmail.com'  
  msg = 'Hello'  
  
  
  # Credentials (if needed)  
  username = 'myemail'  
  password = 'yyyyyy'  
  
  # The actual mail send  
  server = smtplib.SMTP('smtp.gmail.com:587')  
  server.starttls()  
  server.login(username,password)  
  server.sendmail(fromaddr, toaddrs, msg)  
  server.quit()  
  </code></pre>