Skip to content

Instantly share code, notes, and snippets.

@govindsharma7
Forked from anonymous/send_email.py
Created June 3, 2018 05:22
Show Gist options
  • Save govindsharma7/f0afa2165a3998d5c47aadc232cf5152 to your computer and use it in GitHub Desktop.
Save govindsharma7/f0afa2165a3998d5c47aadc232cf5152 to your computer and use it in GitHub Desktop.
# import necessary packages
from email.mime.multipart import MIMEMultipart
from email.mime.text import MIMEText
# For each contact, send the email:
for name, email in zip(names, emails):
msg = MIMEMultipart() # create a message
# add in the actual person name to the message template
message = message_template.substitute(PERSON_NAME=name.title())
# setup the parameters of the message
msg['From']=MY_ADDRESS
msg['To']=email
msg['Subject']="This is TEST"
# add in the message body
msg.attach(MIMEText(message, 'plain'))
# send the message via the server set up earlier.
s.send_message(msg)
del msg
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment