Skip to content

Instantly share code, notes, and snippets.

@arslnb
Created November 14, 2012 12:49
Show Gist options
  • Select an option

  • Save arslnb/4071923 to your computer and use it in GitHub Desktop.

Select an option

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

arslnb commented Nov 14, 2012

Copy link
Copy Markdown
Author

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