Skip to content

Instantly share code, notes, and snippets.

@mmk2410
Last active September 17, 2019 21:47
Show Gist options
  • Save mmk2410/837686d63385b63d1d8b to your computer and use it in GitHub Desktop.
Save mmk2410/837686d63385b63d1d8b to your computer and use it in GitHub Desktop.
twtxt sendmail
#! /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