Created
November 14, 2012 12:49
-
-
Save arslnb/4071923 to your computer and use it in GitHub Desktop.
Sending emails via GMAIL
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def mail(): | |
#Imports the module | |
import smtplib | |
fromaddr = '[email protected]' | |
toaddrs = '[email protected]' | |
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() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This is only a function based on the SMTPLIB module. You have to call it, in whatever manner you want and for whatever reason.