Skip to content

Instantly share code, notes, and snippets.

@trejo08
Last active September 9, 2015 01:21
Show Gist options
  • Save trejo08/764ccc93711ebd454927 to your computer and use it in GitHub Desktop.
Save trejo08/764ccc93711ebd454927 to your computer and use it in GitHub Desktop.
## Script to send emails through Python to remote email
import os
import smtplib
from email.mime.text import MIMEText
from email.mime.imagen import MIMEImage
from email.mime.multipart import MIMEMultipart
#def SendMail(ImageFileName):
def SendMail():
to = "email address"
email_from = "email sender"
# img_data = open(ImageFileName, 'rb').read()
msg = MIMEMultipart()
msg['Subject'] = 'test send image'
msg['From'] = email_from
msg['To'] = to
text = MIMEText("email test form images")
msg.attach(text)
# image = MIMEImage(img_data, name=os.path.basename(ImgFileName))
# msg.attach(image)
s = smtplib.SMTP(server, por)
# s.ehlo()
s.starttls()
# s.ehlo()
s.login(email_from, "password")
s.sendmail(email_from, to, msg.as_string())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment