how to put mozilla linking to a email client?

Discussion of features in Mozilla Firefox
Post Reply
magowiz
Posts: 11
Joined: May 13th, 2004, 7:28 am

Post by magowiz »

I've done it,this should work :

Code: Select all

#script author: asterix, except the "sed", from the icycle script and the first if (I put it)
#http://forums.mozillazine.org/viewtopic.php?p=136157#136157

export MOZILLA_FIVE_HOME=/opt/thunderbird


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

if [ $# == "0" ]; then /opt/thunderbird/thunderbird
else
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:$url;
fi
fi


Hope that someone will find this useful, you can put it as default Gnome or KDE mail program
User avatar
jbelmonte
Posts: 32
Joined: April 8th, 2003, 3:58 am

Post by jbelmonte »

Here is a no-nonsense dispatcher. It should work with any mozilla-compatible mail client.

It takes a few seconds using remote ping (which I consider to be a Thunderbird bug), but this method is very portable.

Code: Select all

#!/bin/sh
#
# Dispatch mailto URL to a mozilla-compatible email client.

MOZ_EMAIL=thunderbird

url=${1/#mailto:}
is_running=`$MOZ_EMAIL -remote "ping()" 2>/dev/null && echo 1`

if [ $is_running ]; then
    $MOZ_EMAIL -remote "mailto($url)"
else
    $MOZ_EMAIL -compose "mailto:$url"
fi
JohnFish
Posts: 2
Joined: May 24th, 2004, 10:46 am

Enable mailto

Post by JohnFish »

Thank you David James and asterix....

I did have to modify the script a little in Firefox for Thunderbird using mozex 1.07 with Linux Mepis (Debian) and the Debian install of both:

Code: Select all

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

export MOZILLA_FIVE_HOME=/usr/bin/

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


I hope this helps someone also.
orka
Posts: 1
Joined: May 26th, 2004, 3:26 am

Post by orka »

Hello
I have a problem with this script.
I change script to use with mozilla, because thunderbird dont works on my stable Debian

Code: Select all

#!/bin/sh
export MOZILLA_FIVE_HOME=/usr/bin
/usr/lib/mozilla/mozilla-bin -mail "$@" &
# next line for testing purposes
echo "$@" > /home/eimantas/mailas

i put this script in /usr/bin/mozilla-mail.sh
and used comand

Code: Select all

chmod +x /usr/bin/mozilla-mail.sh

in my firefox 0.8 i have installed mozex 1.07, i have checked "Intercept mailto clicks"
and in Mailer textbox i entered:

Code: Select all

mozilla-mail.sh %r

before i click on mailto link, i delete file /home/eimantas/mailas and ensure that mozilla is not runing.
When i click on mailto link, nothing was hapend, but in /home/eimantas/mailas file i have one line:
mailto:test@test.com
Ono more thing:
i run terminal and enter:

Code: Select all

eimantas@orka:~$ mozilla-mail.sh "mailto:test@test.com"

it opens my mozilla mail client and everything is fine, and creates /home/eimantas/mailas file
but why in firefox when i click on mailto link my mozilla mail client not opens, but /home/eimantas/mailas have ben crated?
Virtuose TK
Posts: 1720
Joined: March 1st, 2004, 11:16 pm
Contact:

Post by Virtuose TK »

David James wrote:Step-by-step:

Copy the following code that asterix provided (which I have altered only slightly), paste it into a text editor.

Code: Select all

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

export MOZILLA_FIVE_HOME=/usr/local/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 assuming that you've got the thunderbird directory in /usr/local. If you've put it somewhere else, then change as appropriate the export line. Save it as thunderbird-mailto.sh somewhere convenient, such as your home directory.

Next, make the script executable

Code: Select all

chmod +x /path/to/thunderbird-mailto.sh


Finally, with Mozex installed, enter the following into the Mozex settings dialog and be sure that Mozex intercepts mailto: links

Code: Select all

/path/to/thunderbird-mailto.sh %a %s


There, you should be able to open up Thunderbird's composer window from a <a href="mailto:foo@bar.net?subject=Test">mailto link</a>, though you might have to restart Firebird first.

Also, make sure Mozilla isn't running, since Moz will somehow take over. Additionally, Composer can be *very* slow to launch, especially if Thunderbird isn't running. That is why I use kmail for this instead.


It doesn't work with Firefox RC/ Suse Linux 9.0 / Gnome. Why?

..and how I can it configure at gnome mail:protocol ?
jimbudler
Posts: 6
Joined: March 1st, 2004, 2:48 pm

Another version of the script

Post by jimbudler »

With the changes (bugs) in Firefox 0.9 stopping this working, I revisited
this scene and came up with this version which in addition to working with
links allows the right button <Send Image> to open a compose window with the
URL of the image in the body of the message:

Code: Select all

#!/bin/bash
#set -x # Uncomment "set -x" for debugging

TO=$1

if [ "${TO%%:*}" = "mailto" ]; then
TO=${TO#mailto:?} ;
TO=${TO%%&*} ;
BODY=${TO#body=} ;
TO="" ;
else
BODY="" ;
fi

if [ -z $2 ]; then SUBJECT="" ; else SUBJECT=$2 ; fi

thunderbird_running()
{
   /path/to/thunderbird -a thunderbird -remote "mailto($TO?body=$BODY&subject=$SUBJECT)"
}

thunderbird_new()
{
   exec /path/to/thunderbird -P default -compose "mailto:$TO?body=$BODY&subject=$SUBJECT"
}


/path/to/thunderbird -a thunderbird -remote "ping()" > /dev/null 2>&1
if [ $? -ne 0 ]; then
thunderbird_new;
else
thunderbird_running;
fi


Maybe someone else has been bugged by the defective <Send Image>.

Jim ](*,)

David James wrote:Step-by-step:

Copy the following code that asterix provided (which I have altered only slightly), paste it into a text editor.

Code: Select all

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

export MOZILLA_FIVE_HOME=/usr/local/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 assuming that you've got the thunderbird directory in /usr/local. If you've put it somewhere else, then change as appropriate the export line. Save it as thunderbird-mailto.sh somewhere convenient, such as your home directory.

Next, make the script executable

Code: Select all

chmod +x /path/to/thunderbird-mailto.sh


Finally, with Mozex installed, enter the following into the Mozex settings dialog and be sure that Mozex intercepts mailto: links

Code: Select all

/path/to/thunderbird-mailto.sh %a %s


There, you should be able to open up Thunderbird's composer window from a <a href="mailto:foo@bar.net?subject=Test">mailto link</a>, though you might have to restart Firebird first.

Also, make sure Mozilla isn't running, since Moz will somehow take over. Additionally, Composer can be *very* slow to launch, especially if Thunderbird isn't running. That is why I use kmail for this instead.
RKollien
Posts: 2
Joined: July 7th, 2004, 11:06 am

Post by RKollien »

I wonder if anyone was able to install mozex in firebird 0.9(.1) as the API for extensions seems to be changed. Is there a way to get mozex running with ff 0.9?
allanf
Posts: 1
Joined: July 23rd, 2004, 8:50 pm
Location: Twin Cites, MN
Contact:

Post by allanf »

David James wrote:Step-by-step:

Copy the following code that asterix provided (which I have altered only slightly), paste it into a text editor.

Code: Select all

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

export MOZILLA_FIVE_HOME=/usr/local/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 assuming that you've got the thunderbird directory in /usr/local. If you've put it somewhere else, then change as appropriate the export line. Save it as thunderbird-mailto.sh somewhere convenient, such as your home directory.

Next, make the script executable

Code: Select all

chmod +x /path/to/thunderbird-mailto.sh


Finally, with Mozex installed, enter the following into the Mozex settings dialog and be sure that Mozex intercepts mailto: links

Code: Select all

/path/to/thunderbird-mailto.sh %a %s


There, you should be able to open up Thunderbird's composer window from a <a href="mailto:foo@bar.net?subject=Test">mailto link</a>, though you might have to restart Firebird first.

Also, make sure Mozilla isn't running, since Moz will somehow take over. Additionally, Composer can be *very* slow to launch, especially if Thunderbird isn't running. That is why I use kmail for this instead.


This script assumes that only one user is using the box. A better way to check for a running "thunderbird" would be:

Code: Select all

if [  $(ps -u ${USER}  | grep -c thunderbird)  -gt 0 ] ; then
        # you have "thunderbird" running
        $MOZILLA_FIVE_HOME/thunderbird -remote "mailto($1?subject=$2)"
else
        # you do not have "hunderbird" running yet
        $MOZILLA_FIVE_HOME/thunderbird -P default -compose mailto:$1?subject=$2
fi


This is due the fact that "ps aux" will be looking at all processes running and it would see all the thunderbird processes from the other users as well as your own. In my version "pid_count" is 0 when you do not have a running copy of "thunderbird". I olso do not load and run wc to count them as grep's "-c" option will return the count.

Remember when writting Linux scripts that more than one user can be using the box at the same time.
Last edited by allanf on September 7th, 2004, 2:39 pm, edited 1 time in total.
mooreted
Posts: 7
Joined: April 22nd, 2004, 4:32 pm

Post by mooreted »

"Finally, with Mozex installed, enter the following into the Mozex settings dialog and be sure that Mozex intercepts mailto: links"

I don't understand this step. With Firefox open, I enter 'about:config' into the address bar and hit enter. I filter for the word 'mail'. I edit this line: 'helpers-global_mailcap_file' to contain this: '/home/mooreted/thunderbird-mail.sh %a %s'

That doesn't work, so what am I doing wrong?
User avatar
marcpare
Posts: 23
Joined: August 15th, 2004, 3:15 am
Location: Canada

Post by marcpare »

I am using JimBudler' script that he suggested a couple of posts up from this message:

-------------------------------
#!/bin/bash
#set -x # Uncomment "set -x" for debugging

TO=$1

if [ "${TO%%:*}" = "mailto" ]; then
TO=${TO#mailto:?} ;
TO=${TO%%&*} ;
BODY=${TO#body=} ;
TO="" ;
else
BODY="" ;
fi

if [ -z $2 ]; then SUBJECT="" ; else SUBJECT=$2 ; fi

thunderbird_running()
{
/path/to/thunderbird -a thunderbird -remote "mailto($TO?body=$BODY&subject=$SUBJECT)"
}

thunderbird_new()
{
exec /path/to/thunderbird -P default -compose "mailto:$TO?body=$BODY&subject=$SUBJECT"
}


/path/to/thunderbird -a thunderbird -remote "ping()" > /dev/null 2>&1
if [ $? -ne 0 ]; then
thunderbird_new;
else
thunderbird_running;
fi
-------------------------------------------------

This script works well when TB is not running however if TB is running the TB Profile Manager shows and asks for another user. How would I get it to just go to a mailto:? ... My TB is usually running all the time!

Thanks for any help.

Cheers

Marc Paré
wprescott
Posts: 3
Joined: September 6th, 2004, 8:43 am

All working but . . . .

Post by wprescott »

If Thunderbird is running then the profile dialogue opens and I can't use it because it is already running.

Any solutions to that?

Thanks
Dugan
Posts: 2
Joined: April 25th, 2003, 3:28 am

Post by Dugan »

With Firefox 0.93 and Thunderbird 0.73, the solution that works is the one buldir posted in this thread:

Linux mailto script that actually works!

I've tested his solution on both Slackware 10.0 and Debian Sarge, in both cases using the Firefox and Thunderbird packages I downloaded from ftp.mozilla.org.

Note that buldir's solution doesn't use mozex.
hamaryns
Posts: 3
Joined: October 9th, 2006, 3:45 am
Location: Haarlem
Contact:

Post by hamaryns »

TheOneKEA wrote:

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?


The above code is for Thunderbird to use Firefox. The inverse would be
user_pref("network.protocol-handler.app.mailto", "/usr/local/thunderbird/thunderbird");

or, alternatively, add the above property to about:config. (Also possible for the Thunderbird property.)

H.
Post Reply