#bounce a message via mutt but strip off received headers
#so stupid mail systems don't think it's been forwarded too many times
#bind to with
#macro index "B" "<pipe-message>python2.3 /home/ianw/bin/bounce.py<enter>"
#in muttrc
SENDMAIL = "/usr/sbin/sendmail"
YOURMAIL = "ianw@ieee.org"

import email, sys, smtplib, os

m = email.message_from_file(sys.stdin) 
del m['received']

if len(sys.argv) == 2 :
	email = sys.argv[1]
	print "Bouncing to %s" % email
else:

	newstdin = os.open("/dev/tty", os.O_RDONLY)
	os.dup2(newstdin, 0)

	print "Email to send to :",
	sys.stdout.flush()
	email = sys.stdin.readline()

server = smtplib.SMTP('mail.internode.on.net')
server.sendmail(YOURMAIL, email, m.as_string())
server.quit()


