Linux - SoftwareThis forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
I just set this up after much searching and it works for me. I put the info on my blog at http://rignesnet.tzo.com but here is the text for my entry incase someone here might find it useful.
Quote:
I love Firefox but one thing that has been bugging me is getting it to handle mailto URL's in Linux. For some reason there is no actual way to configure this easy in the preferences. So, I Googled about figuring someone has to have done it already but I could only find references to getting Thunderbird and Firefox working together. I like mutt, so I decided to try my hand for the first time ever at actually writing up something that was kind of useful. Well, useful for me anyway.
Inspired by the example helper scripts I saw for Thunderbird I came up with this:
#!/bin/bash
MAILTO_URL="$1"
#Strip off the protocol
MAIL_DATA=$(echo "$MAILTO_URL" | /bin/sed -s 's/^mailto://')
#Get Recipient and strip it off
RECIPIENT=$(echo "$MAIL_DATA" | cut -d? -f1 -)
MAIL_DATA=$(echo "$MAIL_DATA" | /bin/sed -s s/^$RECIPIENT//)
# Call mutt in an aterm
aterm -fg white -bg black -geometry 80x50 -fn 9x15 \
-e mutt "$RECIPIENT" -b "$BCC" -c "$CC" -s "$SUBJECT"
I named this script mailto_helper, made it executable, and stuck it in a logical place for me. Then I opened the URL "about:config" in Firefox. In there I right clicked and created a new string called "network.protocol-handler.app.mailto" with a value of the path to where I put mailto_helper and to my surprise it worked. I'm sure a real programmer/scripter could do something better but I don't think it's all to bad for a novice like me.
I was happy to find your hint
Is there some reason to write a long script?
For me this mailto_helper do the job (and it
send links) :
#!/bin/bash
xterm -e /usr/bin/mutt "$1"
In fact my firefox-1.0 behaves similarly
by default,
but it calls gnome-terminal, and this is
not easy on my slow machine
( I am not using gnome but it is installed)
Actually, I never thought to try just passing the entire mailto URL to mutt so I just tried it now. It looks like, for me at least, that mutt is able to pull the subject out of a mailto URL but it didn't seem to handle the cc and bcc part well, which is what I wanted to cover. So, while the reason I did the long script is because, well, I didn't know mutt would do it, the side effect is that now I know for sure the subject, cc, and bcc fields will be handles correctly.
But, it seems that my little script isn't 100% needed. It was pointed out to me that Show Old Extensions would let you run mozex which is clearly superior to what I wrote if you want to handle other kinds of links.
Of course, there is nothing wrong with using my script if you want to. I'm just happy that someone else has found it useful.
I made an article on my blog that consolidates the info sprinkled about my blog into one place at http://rignesnet.tzo.com/articles/mailto_helper.html . After my last post I chanced it to be a little shorter.
# This script is meant to handle mailto: URLs from Firefox
# and Opera. (I'm using Scientific Linux 6.0 (like RHEL 6.0),
# with Gnome version 2.28.0, and FVWM window manager.)
#
# It first removes the "mailto:" portion of the string it
# receives from the browser, so that $_ becomes merely the
# email address, like "staff@abc.org". Then it should pop
# up a gnome-terminal, within which it executes the mutt
# command, which with this example would be
# "mutt staff@abc.org".
#
# To get it to work properly:
# In System --> Preferences --> Preferred Applications, select
# for the mail reader "Custom", and insert the command
# "mailto_handler %s", and uncheck the "Run in terminal" box.
#
# Also in the gnome-terminal:
# Edit --> Profile Preferences --> Title and Command, choose
# "Exit the terminal" when command exits.
# Then when you click on a mailto URL the gnome-terminal
# window that pops up should say, at the bottom,
# "To: staff@abc.org", and you are set to send your email.
#
# It also works for Opera, but for Opera, go to
# Tools --> Preferences --> Advanced --> Programs, and edit
# the "mailto" Protocol to specify "Open with other application",
# where you should insert the command "mailto_handler" (no %s),
# with nothing in the "Parameter" field, and again leave the
# "Open in terminal" box unchecked.
I get
xterm: Can't execvp read: No such file or directory
So that's not working...how can I give myself the choice when I click these links?
(gmx is aliased to "mutt -F .guttrc", which accesses gmx.com mail over imap, while "mutt" just calls with the .muttrc for accessing gmail over imap).
In the meantime, I have FF (iceweasel, really) calling thunderbird (icedove, really), which is set up for both, and I can choose, but even having icedove (or any gui-pop-mailer, like sylpheed or whatever) installed, solely for this purpose, seems like overkill, since I generally read my mail in mutt, or, occasionally, on the web interfaces for these services, but never in icedove.
I suppose I could just copy/paste an e-mail address to my terminal (gnome-terminator allows pasting, unlike xterm), but clicking the link and having mutt come up, with a choice of configs, would be much cooler.
#!/usr/bin/perl
# updated mailto_handler to include the possible parts of
# "subject", "cc" and "bcc", should they exist in the "mailto"
# URL. ("body" is not included.) The format of a "mailto"
# URL that includes subject, cc and bcc would be this:
#
# "mailto:foo@bar.org,a@bc.org?subject=test one&cc=d@ef.com&bcc=g@hi.edu"
#
# most browsers will replace spaces by the "%20" string, since
# that's the proper way to encode URLs. However one does not want
# a multi-word "subject" (e.g. "test one") to appear as
# "test%20one" in a subject line. So at the end of the script, we
# convert, in the command line, all %20s to spaces before sending
# the command line to mutt. NOTE: do not use "?" or "&" in the
# subject field. This script will fail if you do.
#
# The idea is that if one clicks on a "mailto' link, a
# gnome-terminal should pop up, within which a mutt command
# will be issued. With the above "mailto" example URL, the mutt
# command emitted would be
#
# "mutt foo@bar.org,a@bc.org -s 'test one' -c 'd@ef.com' -b 'g@hi.edu'"
#
# Of course, the usual "mailto:foo@bar.org" as a URL will work
# just fine.
#
# To get it to work with gnome:
# in System --> Preferences --> Preferred Applications, select
# for the mail reader "Custom", and insert the command
# 'mailto_handler %s', and uncheck the "Run in terminal" box.
#
# Also in a gnome-terminal:
# Edit --> Profile Preferences --> Title and Command, choose
# "Exit the terminal" when command exits.
#
# For Opera: Tools --> Preferences --> Advanced --> Programs,
# and edit the "mailto" Protocol to specify "Open with other
# applicataion", insert the command "mailto_handler" (no %s),
# with nothing in the "Parameter" field, and again leave the
# "Open in terminal" box unchecked.
#
# Updated December 04, 2011
#
$_ = $ARGV[0];
chomp;
s/^mailto://; # strip off the "mailto:"
my @parts = split /\?/, $_;
my $numparts = @parts + 0;
my $email = "$parts[0]"; # there will always be $parts[0]
my $cmd = "mutt $email ";
if ($numparts > 1) { # if there's more, grab the data
if ($numparts != 2) {
die ("too many '?' chars; only one allowed");
}
my @rest = split /&/, $parts[1]; # get subject, cc, bcc
foreach $field (@rest) {
if ($field =~ /^subject=/) {
$subject = substr($field, 8);
$cmd .= "-s '$subject' ";
}
if ($field =~ /^cc=/) {
$cc = substr($field, 3);
$cmd .= "-c '$cc' ";
}
if ($field =~ /^bcc=/) {
$bcc = substr($field, 4);
$cmd .= "-b '$bcc' ";
}
}
}
# replace any "%20" strings inserted by browser by space char.
$_ = $cmd;
s/%20/ /g;
`gnome-terminal -e "$_"`
###########################################################
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.