how to put mozilla linking to a email client?

Discussion of features in Mozilla Firefox
Post Reply
Artcfox
Posts: 1
Joined: September 16th, 2003, 4:20 pm

Post by Artcfox »

Thanks David for your wonderful script!

However I ran into a problem using it. Thunderbird was not running, though I did have a process running which had the string "thunderbird" as part of an argument. (nano -w /usr/local/bin/thunderbird-mailto.sh) I then clicked on a mailto: link, and it did not run Thunderbird. I eventually traced it back to it falsely detecting an already running instance of Thunderbird.

I modified the script to use a more robust way of detecting if the process is already running. I also quoted what is after the -compose argument.

Code: Select all

export MOZILLA_FIVE_HOME="/usr/lib/MozillaThunderbird"
THUNDERBIRD_PATH="/usr/lib/MozillaThunderbird"
                                                                                                               
if [ -z "`/bin/ps x | /bin/grep \"[0-9] ${THUNDERBIRD_PATH}/thunderbird-bin\"`" ]; then
    # No MozillaThunderbird running
    ${THUNDERBIRD_PATH}/thunderbird -P default -compose "mailto:$1?subject=$2"
else
    # MozillaThunderbird running
    ${THUNDERBIRD_PATH}/thunderbird -remote "mailto($1?subject=$2)"
fi
darksarin
Posts: 3
Joined: November 14th, 2003, 9:57 am
Contact:

hmmm

Post by darksarin »

I am having the same problem as some others. I used the script provided by david james, and then issued this command:
chmod +x thunderbird-mailto.sh

I then entered this into the mozex extions options dialog under "mailer"
/home/ben/files/thunderbird/thunderbird-mailto.sh -P default -compose mailto:%a?subject=%s


I also tried this:
/home/ben/files/thunderbird/thunderbird-mailto.sh %a %s


This does not work under either gnome or xfce4. Any ideas? I am at a total loss.
magnum3065
Posts: 2
Joined: April 8th, 2003, 2:58 pm

Post by magnum3065 »

People seem to be blaming problems with the scripts on the WM/Desktop environment, but I imagine more problems are actually due to the different distros people are running. I use Debian and the scripts listed didn't work because they didn't reflect the directories that my program was actually stored in. Try checking the directory names and the program used to launch Thunderbird and make sure that they're properly edited in the script.

The modified version of the script that works for me in Debian is:
#!/bin/sh
export MOZILLA_FIVE_HOME="/usr/lib/mozilla-thunderbird"
THUNDERBIRD_PATH="/usr/lib/mozilla-thunderbird"

if [ -z "`/bin/ps x | /bin/grep \"[0-9] ${THUNDERBIRD_PATH}/mozilla-thunderbird-bin\"`" ]; then
# No MozillaThunderbird running
mozilla-thunderbird -P default -compose "mailto:$1?subject=$2"
else
# MozillaThunderbird running
mozilla-thunderbird -remote "mailto($1?subject=$2)"
fi
fin
Posts: 14
Joined: February 11th, 2004, 10:40 am
Location: Scotland

Post by fin »

I have the same problem here. I can run the script simply by clicking on it but when I enter the command "/home/fin/thunderbird-mailto.sh %a %s " into mozex, I get nothing when I click on a mailto link. I've taken to using Kmail for the mailto protocol which is a bit of a nuisance.
My thunderbird-mailto.sh reads:
#!/bin/sh
#
#script author: asterix
#http://forums.mozillazine.org/viewtopic.php?p=136157#136157

export MOZILLA_FIVE_HOME=/home/fin/thunderbird

if [ $(ps aux | grep thunderbird | wc -l) -gt 4 ]; then
# thunderbird is running (thunderbird est lance)
$MOZILLA_FIVE_HOME/thunderbird -remote "mailto($1?subject=$2)"
else
# thunderbird is not running (thunderbird n'est pas lance)
$MOZILLA_FIVE_HOME/thunderbird -P default -compose mailto:$1?subject=$2;fi

I'm baffled.
fin
Posts: 14
Joined: February 11th, 2004, 10:40 am
Location: Scotland

Post by fin »

NOW I understand part of the problem. In order to enable Thunderbird to use Firefox to open links I had to write a script called browser.sh in which I placed the line:"export MOZILLA_FIVE_HOME=/home/fin/firefox". So- a little conflict of interest, eh? This is the only way I can get Thunderbird to use Firefox. So I can't get Firefox to use Thundrbird! Hmm.
There must be a way of dioing this.
KDE 3.1 on Mandrake 9.2.

Finlay
matt_morgan
Posts: 4
Joined: November 12th, 2003, 8:35 am
Location: Brooklyn, NY
Contact:

Change to asterix's script

Post by matt_morgan »

I found on my computer that Thunderbird creates fewer processes. I have no idea why. But to get that script to work right, I had to change the '-gt 4' to '-gt 1'.
TheOneKEA
Posts: 4864
Joined: October 16th, 2003, 5:47 am
Location: Somewhere in London, riding the Underground

Post by TheOneKEA »

Er....

Code: Select all

/* Tell Thunderbird to use my Firefox launching script */
user_pref("network.protocol-handler.app.http", "/usr/local/bin/firefoxURL.sh");


???

Has this been said already?
Proud user of teh Fox of Fire
Registered Linux User #289618
amistry
Posts: 1
Joined: March 26th, 2004, 2:42 pm

Post by amistry »

This is for any FreeBSD users, it elimiates the mailto error when trying to use a modified version of the previous script:

Code: Select all

#!/bin/sh
#
#script author: asterix
#http://forums.mozillazine.org/viewtopic.php?p=136157#136157

export MOZILLA_FIVE_HOME=/usr/X11R6/lib/thunderbird/lib/mozilla-1.6

if [ $(ps auxww | grep thunderbird-bin | grep -v grep | wc -l) -gt 0 ]; then
# thunderbird is running (thunderbird est lance)
        $MOZILLA_FIVE_HOME/run-mozilla.sh $MOZILLA_FIVE_HOME/thunderbird-bin -remote  "mailto($1?subject=$2)"
else
# thunderbird is not running (thunderbird n'est pas lance)
        $MOZILLA_FIVE_HOME/run-mozilla.sh $MOZILLA_FIVE_HOME/thunderbird-bin -P default -compose "mailto:$1?subject=$2"
fi

diedericr
Posts: 2
Joined: March 29th, 2004, 9:52 pm

mailto

Post by diedericr »

Hi
I've got some problems with Firefox 0.8:
I'm using: Mandrake L 10.0, KDE 3.2;
I've placed firefox in /home/diederic/applications/firefox
I've saved the file /firefox-maito.sh the above directory
Using midnight commander I've made the file executable for evyone
In the mozex extension I've ticked mailto and in the mailer box I've put the path to the file firefox-mailto.sh

If I click on an email address in a some web sites I get the meddage: mailto not a registered protocol;

What am I doing wrong?

Many thanks,
Diederic
icycle
Posts: 21
Joined: March 23rd, 2004, 9:19 am

A "better" mailto handling script for Linux tbird/

Post by icycle »

A "better" mailto handling script for Linux tbird/firefox

I first grabbed the default script shown earlier in this thread and realized it wasn't handling message bodies nor any other headers (CC, BCC, etc). A bit of research and I realized I could either create a script which handles all arguments (subject, body, cc, etc) separately -- i.e. break down the whole mailto URL from firefox/mozex and then reassemble it for thunderbird OR I could use the very handy mozex %r variable which is the unmodified URL which feeds nicely into thunderbird.

The result is the following (very simple) script:

Code: Select all

#!/bin/sh

url="$1"

export MOZILLA_FIVE_HOME=/opt/thunderbird/current

if [ $(pidof thunderbird-bin | wc -w) -gt 4 ]; then
    # thunderbird is running
    url=`echo "$url" | sed -e's/^mailto://'`
    $MOZILLA_FIVE_HOME/thunderbird -remote "mailto($url)"
else
    # thunderbird is not running
    $MOZILLA_FIVE_HOME/thunderbird -P default -compose $url
fi


To use this, simply install mozex and set it to intercept mailto using the above script as follows:

Code: Select all

/path/to/script %r

then restart (after mozex install) <b>both</b> firefox and thunderbird. And of course, make sure the script is executable.
matt_morgan
Posts: 4
Joined: November 12th, 2003, 8:35 am
Location: Brooklyn, NY
Contact:

Post by matt_morgan »

Cool!

Couple minor points:

1) pidof is not in my user path by default. On my system (Fedora Core 1) at least, it's in /sbin so using

/sbin/pidof

may work better.

2) Again, I have only one Thunderbird process running most of the time. Not sure why everyone else has more than four; in any case, I would normally need to use

if [ $(/sbin/pidof thunderbird-bin | wc -w) -gt 0 ]; then

to get a true result when thunderbird is running.
icycle
Posts: 21
Joined: March 23rd, 2004, 9:19 am

Post by icycle »

Thanks Matt,

I should have checked where pidof was coming from. I also forgot to mention to newbies that the path to thunderbird also would need modifications on their system. And I guess if there are either 1 or 4 tbird processes present then the application is running. I don't understand the magic number 4 either :-)

I was thinking to myself last night that even though this type of interaction should "just work" I still love the fact that the user has this much control of what is happening. I can't imagine doing anything this custom on any microsoft based product. But then again, no one usually needs to.

There are arguments on both sides...I have converted 100% to Liinux and see no reason to go back. Open source is where the power is.
User avatar
khurtwilliams
Posts: 8
Joined: February 10th, 2004, 7:32 am
Location: Princeton
Contact:

Does nothing

Post by khurtwilliams »

I followed these instructions and Firefox 0.8 still does nothing when I click on a mailto: link. The script executes and runs fine from the command line though.
Linux, Perl and Security consulting.
http://www.williamsinteractive.com
icycle
Posts: 21
Joined: March 23rd, 2004, 9:19 am

Post by icycle »

khurtwilliams wrote:I followed these instructions and Firefox 0.8 still does nothing when I click on a mailto: link. The script executes and runs fine from the command line though.
k,

Have you:
-installed mozex
-configured mozex to intercept mailto and provided an absolute path to your script with %r as the only argument
-restarted both thunderbird and firefox
-verified the script is executable (should be since you can exec it from the CLI)

when you click on mailto link, such as <a href="mailto:hello@world.nul?subject=test&body=this%20is%20a%20test&cc=joe@nul.nul">this one</a>, do you see any popups from firefox saying "mailto is not a registered protocol"? I actually see that on my browser right now, not sure why, but if I dismiss it, the thunderbird mail window still opens correctly. But if you don't see anything at all, then review all of the steps again.

HTH,
Brett
magowiz
Posts: 11
Joined: May 13th, 2004, 7:28 am

Post by magowiz »

Hi all,
I have a problem using this script in gnome:

I'm running gnome2.4 and this script that handles mailto links:

Code: Select all

#!/bin/sh
#
#script author: asterix
#http://forums.mozillazine.org/viewtopic.php?p=136157#136157

export MOZILLA_FIVE_HOME=/opt/thunderbird

url=`echo "$1" | sed -e's/^mailto://'`


if [ $(ps aux | grep thunderbird | wc -l) -gt 4 ]; then
# thunderbird is running (thunderbird est lance)
        $MOZILLA_FIVE_HOME/thunderbird -remote "mailto($url)"
else
# thunderbird is not running (thunderbird n'est pas lance)
        $MOZILLA_FIVE_HOME/thunderbird -P default -compose mailto:$1?subject=$2;
fi




i would like to set this script as my default mailto handler (in control panel->file types and programs->mailto)and also to set as my favourite application the main program(the thunderbird binary:/opt/thunderbird/thunderbird) .
The problem is that if I set mailto handler to use my script, GNOME set it also as my favourite mail client.
It's possible to modify this script to open Thunderbird Main Program instead of the composer if I invoke the script with no arguments?
Post Reply