Skip to content

Instantly share code, notes, and snippets.

@arslnb
Created November 14, 2012 12:49
Show Gist options
  • Save arslnb/4071923 to your computer and use it in GitHub Desktop.
Save arslnb/4071923 to your computer and use it in GitHub Desktop.
Sending emails via GMAIL
def mail():
#Imports the module
import smtplib
fromaddr = 'example_one@gmail.com'
toaddrs = 'example_two@gmail.com'
msg = "Sent via python"
# Authentication
username = 'username'
password = 'password'
# Send code
server = smtplib.SMTP('smtp.gmail.com:587')
server.starttls()
server.login(username,password)
server.sendmail(fromaddr, toaddrs, msg)
server.quit()
@arslnb
Copy link
Author

arslnb commented Nov 14, 2012

This is only a function based on the SMTPLIB module. You have to call it, in whatever manner you want and for whatever reason.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment