#!/usr/bin/python # Copyright 2015 (c) Anna Schumaker. import slack import smtplib from email.mime.text import MIMEText import textwrap s = smtplib.SMTP("localhost") repl = "--- Reply above this line ---".ljust(40) for channel in slack.channels.list(): if not channel.is_member(): continue if channel.unread_count() == 0 or channel.unread_count() == None: continue chan = ("channel=%s" % channel.id()).rjust(40) text = [ "", "%s%s" % (repl, chan), ""] 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"] = "SlackMail@OcarinaProject.net" msg["To"] = slack.user().email() s.sendmail(slack.team(), slack.user().email(), msg.as_string()) s.quit()