Skip to content

Instantly share code, notes, and snippets.

@AbhinavMadahar
Created October 2, 2016 02:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save AbhinavMadahar/c37b8153068a777e1346c9733586f709 to your computer and use it in GitHub Desktop.
Save AbhinavMadahar/c37b8153068a777e1346c9733586f709 to your computer and use it in GitHub Desktop.
# import modules needed to send emails
import smtplib
from getpass import getpass
# sends a message to the recipient_email
def send(recipient_email, message):
if not ("@" in recipient_email):
raise Exception("Must have an @ in an email address")
try:
password = getpass("What's your password?")
server = smtplib.SMTP('smtp.gmail.com:587')
server.ehlo()
server.starttls()
server.login(organizer_email, password)
server.sendmail(organizer_email, recipient_email, message)
server.quit()
print("Sent")
except:
print("Wrong password")
send(recipient, message)
# takes some info and stuffs it into an email template
def body(person, company):
body = ""
body += "Hi " + person + "!,\n\n"
body += "I'm " + organizer_name + ", an organizer for hackMHS III, the second largest high "
body += "school hackathon in New Jersey! In a hackathon, students can learn how to program "
body += "and have some friendly competition. We plan on having over 100 hackers attend this "
body += "Dec 3rd in a 12-hour hackathon, and we would love it if " + company + " sponsored us!"
body += " Basically, " + company + " would donate some money in exchange for advertizing in "
body += "front of over a hundred high schoolers in one of the richest towns in America for 12 "
body += "hours. We use the money to provide an amazing experience and " + company + " uses "
body += "the advertizing to get more customers. More info can be found on our website, "
body += "millburnhacks.com/hackmhs/iii/sponsors.\n\n"
body += "If you're interested, I'd love to talk about a sponsorship deal.\n\n"
body += "Thanks,\n"
body += organizer_name
return body
organizer_name = "" or input("What is your name? ")
organizer_email = "" or input("What is your email? ")
while True:
print("")
print("Now emailing a new company")
email = input("What's the company representative's email? ")
name = input("What's the person's name? ")
company = input("What's their company's name? ")
send(email, body(name, company))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment