#!/usr/bin/python # Copyright 2015 (c) Anna Schumaker. import slack import smtplib from email.mime.text import MIMEText s = smtplib.SMTP("localhost") for channel in slack.channels.list(): if not channel.is_member(): continue if channel.unread_count() == 0 or channel.unread_count() == None: continue text = [ str(channel) ] + [ "" ] for message in channel.read(): text += [ str(message) ] print("\n".join(text)) print() msg = MIMEText("\n".join(text)) msg["Subject"] = "[%s] %s" % (slack.team(), channel.name()) msg["From"] = "slack@OcarinaProject.net" msg["To"] = "schumaker.anna@gmail.com" s.sendmail("SlackMail", "schumaker.anna@gmail.com", msg.as_string()) s.quit()