On Thu, Nov 24, 2011 at 01:44:03PM +0000, Chris Green wrote:
> I have a pretty standard Firefox 3.6.24 running in xubuntu.
>
> I have mutt set as my default E-Mail application in Preferred
> Applications and in Firefox's preferences. However it's not working
> properly, when I click on a mailto: link an empty E-Mail gets sent.
>
> It looks to me as if this is something to do with mutt needing a
> terminal window to run in but all the menus seem to know about mutt
> already as if they should know this.
>
> Can anyone suggest what might be wrong?
attached a simple script that is use. set it executable and call this
from firefox, not mutt directly
#!/usr/bin/env python
from __future__ import with_statement
import os
import sys
import cgi
import urlparse
import subprocess
import tempfile
import contextlib
tmpfile = None
@contextlib.contextmanager
def fdopen(fd, mode='r', bufsize=-1):
yield os.fdopen(fd, mode, bufsize)
def simpleParam(hname):
def _(hvalue):
return hname, hvalue
return _
def bodyParam(hvalue):
global tmpfile
fd, filename = tempfile.mkstemp()
tmpfile = filename
with fdopen(fd, 'w') as fp:
fp.write(hvalue)
return '-i', filename
ARGS = {
'subject': simpleParam('-s'),
'bcc': simpleParam('-b'),
'cc': simpleParam('-c'),
'body': bodyParam,
}
def filterParams(name):
return name in ARGS
def parsequery(query):
args = []
parts = urlparse.urlparse(query, scheme='mailto')
to = parts[2]
if to.find('?') > 0:
to, params = to.split('?', 1)
params = cgi.parse_qs(params)
for name in filter(filterParams, params):
hvalue = ','.join(params[name])
args += ARGS[name](hvalue)
args += ['--', to]
return args
if len(sys.argv) == 1:
print >> sys.stderr, 'Usage: %s address' % sys.argv[0]
sys.exit(1)
args = ['xterm', '-e', 'mutt'] + parsequery(sys.argv[1])
retcode = subprocess.call(args)
if tmpfile and os.path.exists(tmpfile):
os.unlink(tmpfile)
sys.exit(retcode)