Created
August 8, 2011 20:14
-
-
Save jakl/1132612 to your computer and use it in GitHub Desktop.
Send an email using python and your gmail smtp
This file contains 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
#!/usr/bin/python | |
import os | |
import smtplib | |
import mimetypes | |
from email.MIMEMultipart import MIMEMultipart | |
from email.MIMEText import MIMEText | |
def sendMail(subject, text): | |
gmailUser = 'jediknight304@gmail.com' | |
gmailPassword = 'like I|d give you this that easily....' | |
recipient = 'james.ross.koval@gmail.com' | |
msg = MIMEMultipart() | |
msg['From'] = gmailUser | |
msg['To'] = recipient | |
msg['Subject'] = subject | |
msg.attach(MIMEText(text, 'html')) | |
mailServer = smtplib.SMTP('smtp.gmail.com', 587) | |
mailServer.ehlo() | |
mailServer.starttls() | |
mailServer.ehlo() | |
mailServer.login(gmailUser, gmailPassword) | |
mailServer.sendmail(gmailUser, recipient, msg.as_string()) | |
mailServer.close() | |
print('Sent email to %s' % recipient) | |
sendMail('this is whack', '<head>this is the head</head><body>and here comes <a href="google.com">the hook!</a></body>') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment