Last active
September 17, 2019 21:47
-
-
Save mmk2410/837686d63385b63d1d8b to your computer and use it in GitHub Desktop.
twtxt sendmail
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
#! /usr/bin/env python3 | |
import smtplib | |
import socket | |
import getpass | |
hostname = socket.gethostname() | |
username = getpass.getuser() | |
sender = 'twtxt@' + username + '.' + hostname | |
receivers = ['someone@example.com'] | |
subject = "[twtxt-mention] You have been mentioned" | |
theMentioner = 'theevili' | |
tweet="Hi @someone" | |
message = """From: {} | |
To: {} | |
Subject: {} | |
You have been mentioned by {}: | |
"{}" | |
""".format(sender, receivers[0], subject, theMentioner, tweet) | |
smtpObj = smtplib.SMTP('localhost') | |
smtpObj.sendmail(sender, receivers, message) | |
smtpObj.quit() | |
print("Mail sent") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment