title: How do I send an email with a .csv attachment using Python
body: <p>Okay, I know there is a few questions out there addressing this, but I cannot find a way to make it work properly. I would assume it is as simple as the below code, but this does not attach my file. Any help would be greatly appreciated. I am also very new to Python. Is there a mail module that I should be importing to make the function work?</p>
  
  <pre><code>import smtplib
  fromaddr = "example@example.com
  toaddrs = "reciever@example.com
  
  msg = "help I cannot send an attachment to save my life"
  attach = ("csvonDesktp.csv")
  
  username = user
  password = password
  
  server = smtplib.SMTP('smtp.gmail.com:587')
  server.starttls()
  server.login(username,password)
  server.sendmail(fromaddr, toaddrs, msg, attach)
  server.quit()
  </code></pre>