Skip to content

Instantly share code, notes, and snippets.

@anishathalye
Created June 26, 2016 03:58
Show Gist options
  • Save anishathalye/03a9ff0036808ae6e469acd96f77f066 to your computer and use it in GitHub Desktop.
Save anishathalye/03a9ff0036808ae6e469acd96f77f066 to your computer and use it in GitHub Desktop.
import smtplib
import csv
from getpass import getpass
server = smtplib.SMTP('smtp.gmail.com', 587)
server.ehlo()
server.starttls()
server.ehlo()
user = raw_input('Gmail username: ')
password = getpass()
server.login(user, password)
from email.MIMEMultipart import MIMEMultipart
from email.MIMEText import MIMEText
fromAddr = '%s@gmail.com' % user
with open('annotators.csv') as f:
reader = csv.reader(f)
for row in list(reader)[1:]:
name, email, description, secret = row
msg = MIMEMultipart()
msg['From'] = fromAddr
msg['To'] = email
msg['Subject'] = "[HackMIT] Important: Judging System Access"
link = 'http://judge.hackmit.org/login/%s' % secret
body = "Hi %s,\n\nWelcome to the HackMIT judging - this email contains your magic link to the judging system.\n\nIf you are no longer judging, please DO NOT access the link - it will affect judging results!\n\nDO NOT SHARE your magic link with others - it is associated with your email address, and it's one account per person.\n\nJudging will be explained at judging orientation at 10:30am in the Johnson lobby - please don't open the link until then.\n\nYou may sign in to judging by accessing the following link:\n\n%s\n\nQuestions should be directed to HackMIT organizers.\n\n--Anish\nOn behalf of the HackMIT Team" % (name, link)
msg.attach(MIMEText(body, 'plain'))
text = msg.as_string()
print msg
server.sendmail(fromAddr, email, text)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment