Skip to content

Instantly share code, notes, and snippets.

@sirhcsenots
Created March 26, 2016 02:56
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 sirhcsenots/a7273a85c623f66cb2cc to your computer and use it in GitHub Desktop.
Save sirhcsenots/a7273a85c623f66cb2cc to your computer and use it in GitHub Desktop.
Send a short poem to someone important in your life. Poem shows up in the subject lines of the email inbox.
# Inbox Poem Sender
# Concept by Chris Stones
# welcometochrisworld.com
# March 24, 2009
#
# Fantastic gmail email code by
# http://kutuma.blogspot.com/2007/08/sending-emails-via-gmail-with-python.html
import time
import smtplib
from email.MIMEMultipart import MIMEMultipart
from email.MIMEBase import MIMEBase
from email.MIMEText import MIMEText
from email import Encoders
import os
gmail_user = "YOURGMAIL@gmail.com"
gmail_pwd = "YOUR_GMAIL_PASSWORD"
def mail(to, subject, text): #, attach):
msg = MIMEMultipart()
msg['From'] = gmail_user
msg['To'] = to
msg['Subject'] = subject
msg.attach(MIMEText(text))
mailServer = smtplib.SMTP("smtp.gmail.com", 587)
mailServer.ehlo()
mailServer.starttls()
mailServer.ehlo()
mailServer.login(gmail_user, gmail_pwd)
mailServer.sendmail(gmail_user, to, msg.as_string())
# Should be mailServer.quit(), but that crashes...
mailServer.close()
to_her = "ToHERorHIM@theiraddress.com"
# the poem part
# Your poem should be a list of strings
poem = ["Simple to hear",
"to Listen to touch",
"But so far away",
"almost a crutch",
"still you are here",
"at home in my heart",
"and so functionally speaking",
"we never do part"]
# when the e mails are in the inbox they are first line last
# so we send in reverse order
poem.reverse()
for line in poem:
# delay so that packets can reach
# their destination despite network delay effects
time.sleep(10)
mail(to_her,line,line)
#nothing to it
@sirhcsenots
Copy link
Author

Could use a serious update. Perhaps, something that uses the OAuth tokens etc. And a cli interface.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment