Skip to content

@galvez /try_sending_email.py
Created

Embed URL

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
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.