#!/usr/bin/python3

from urllib import quote as q
from email import message_from_file
from email.Utils import parseaddr
from sys import stdin
import os

text="""I'm subscribed to the list, no need to CC me:

https://www.debian.org/MailingLists/#codeofconduct

No need to reply to this message."""

msg = message_from_file(stdin)

(name, addr) = parseaddr(msg['from'])
subject = msg['subject']
date = msg['date']
msgid = msg['message-id'][1:-1]

if subject[0:4] .lower() != 're: ':
    subject = 'Re: '+subject

body =  'On ' + date + ', ' + name + ' wrote stuff' + '\n\n' + text

url = 'mailto:'+q(addr)+'?subject='+q(subject)+'&in-reply-to='+q(msgid)+'&body='+q(body)

os.spawnlp(os.P_NOWAIT, 'evolution', 'evolution', url)
