Created

Embed URL

HTTPS clone URL

SSH clone URL

You can clone with HTTPS or SSH.

Download Gist
View try_sending_email.py
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
def try_sending_email():
import os, smtplib, mimetypes
from email.MIMEMultipart import MIMEMultipart
from email.MIMEBase import MIMEBase
from email.MIMEText import MIMEText
from email.Encoders import encode_base64
gmail_user = '[user]@gmail.com'
gmail_password = '[password]'
recipient = '[recipient]'
msg = MIMEMultipart()
msg['From'] = gmail_user
msg['To'] = recipient
msg['Subject'] = 'Hello!'
msg.attach(MIMEText('Hello'))
mail_server = smtplib.SMTP('smtp.gmail.com', 587)
mail_server.set_debuglevel(1)
mail_server.ehlo()
mail_server.starttls()
mail_server.ehlo()
mail_server.login(gmail_user, gmail_password)
mail_server.sendmail(gmail_user, recipient, msg.as_string())
mail_server.close()
print('Sent email to %s' % recipient)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.