Created
March 26, 2016 02:56
-
-
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.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Could use a serious update. Perhaps, something that uses the OAuth tokens etc. And a cli interface.