#!/usr/bin/env python


# used in procmail via pipe when routing spam to it
# writes from, subject, brief body text as summary

import email, os, sys

raw_msg = sys.stdin.read()
msg = email.message_from_string(raw_msg)

msgfrom = msg['From']
subject = msg['Subject']

if not msg.is_multipart():
	snippet= msg.get_payload()[0:150]
else:
	snippet = ""

outfile = open("spam_summary", "a")
outfile.write("From: %s \n" % msgfrom)
outfile.write("Subject: %s \n" % subject)
outfile.write("Body: %s \n" % snippet)
outfile.write("--\n")
outfile.close()



Syntax highlighted by code2html, ver. $Rev: 17 $