[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Firefox 1.0, mailto, and mutt



On Fri, 26 Nov 2004, Jim McCloskey wrote:

> I asked earlier:
> 
> |> I used mozex with earlier versions of Firefox to bring up mutt in
> |> response to clicking on mailto links.
> |>
> |> Does anyone know of a way of doing this also with Firefox 1.0?
> 
> Thanks very much indeed to all who responded. I ended up using the
> `launchy' extension. This proved troublesome at first because every
> effort to use it failed with the error:

I missed this thread earlier.  FWIW, here's my firefox mailto: handler
(using Launchy).  I use it to ssh over to my maildrop machine.  Perhaps it
will make a useful template for others.

------------------------------------
#! /usr/bin/perl

# Helper program for mozilla and mutt.
#   Brad Sawatzky <brad+debian@lamorak.phys.virginia.edu>
#
# This is for use with the 'Launchy' extension.  Create a file named
# 'launchy.xml' in the users (or global) chrome directory that contains the
# following (without the hash marks).
#
# <?xml version="1.0" encoding="UTF-8"?>
# <configurations xmlns="http://launchy.mozdev.org/configurations";>
#	<application>
#		<label>Mutt</label>
#		<type>2</type>
#		<command>~/bin/mailto</command>
#		<arguments></arguments>
#	</application>
#</configurations>
#
# Rename this perl script to '~/bin/mailto', and make it executable.
# Install the 'Launchy' extension and right-click on a 'mailto:' URL for
# muttly goodness.

my $test = 0;   # if non-zero then watch 'tail ~/.xsession-errors' (for example)
my $XTERM="/usr/bin/xfterm";
my $REMCMD="ssh -t foo\@bar.com";

my @ADDRESSES=();
my $BODY="";
$PATH="";
my $ARGS = join (' ', @ARGV);
if($test) { warn "invocation: $0 $ARGS\n";}

## Parse mailto: line using rfc2368
# <http://www.ianr.unl.edu/internet/mailto.html>
# <http://www.faqs.org/rfcs/rfc2368.html>
if( $ARGS =~ /^mailto:(.*)/ ) {
  my @globs = split(/,/, "$1");

  for my $glob (@globs) {
    if($test) { warn "  glob: $glob\n";}
    my @mainblobs = split(/\?/,"$glob");
    ## first field should be an email address
    push @ADDRESSES, shift @mainblobs;
    if($test) { warn "  ADDR: " . join(',',@ADDRESSES) . "\n"; }


    for my $headerblob (@mainblobs) {
      if($test) { warn "    headerblob: $headerblob\n"; }
      ## The rest are header options
      my @headers = split(/\&/, "$headerblob");
      for my $header (@headers) {
        if($test) { warn "      header: $header\n"; }
        my ($fld,$val) = split(/=/, "$header");
        for(lc($fld)) {
          if($test) { warn "        fld: $fld\n"; }
          if    (/^cc$/) {
            push @MAILARGS, "-c \"$val\" ";
          }
          elsif (/^bcc$/) {
            push @MAILARGS, "-b \"$val\" ";
          }
          elsif (/^to$/) {
            push @ADDRESSES, "$val";
          }
          elsif (/^subject$/) {
            push @MAILARGS, "-s \"$val\" ";
          }
          elsif (/^body$/) {
            $BODY.="$val\n";
          }

        } # done fld switch statement
      } # done header field loop
    } # done headerblob loop
  } # done mainblob (should really be only one of these...)
}

my $ADDLIST = join(" ", @ADDRESSES);
my $ARGLIST = join(" ", @MAILARGS);

## FIXME:  ignoring body for now.
## Not sure what to do with the body.  'mutt' supports including a file with
#  a header option, but that won't work if you ssh over to another machine...
#  Maybe fork off an xterm with the body to allow copy and pasting?

if($test) {warn "$XTERM -e '$REMCMD mutt $ARGLIST $ADDLIST'";}

exec "$XTERM -e '$REMCMD mutt $ARGLIST $ADDLIST'";
------------------------------------

-- Brad



Reply to: