Linux users!How to run Thunderbird from Firefox & vice v

Discussion of general topics about Mozilla Thunderbird
Post Reply
gbil
Posts: 41
Joined: January 10th, 2003, 1:24 am

Linux users!How to run Thunderbird from Firefox & vice v

Post by gbil »

Ok after some searching I decided to sum the methods of running Thunderbird after clicking a mailto or news url in Firefox and how to make Thunderbird open a url in Firefox.

Firefox to Thunderbird
1. Copy-paste the following codes into 2 seperate files, mailto-thunderbird.sh and newsto-thunderbird.sh

mailto-thunderbird.sh

Code: Select all

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

export MOZILLA_FIVE_HOME=/location/to/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


newsto-thunderbird.sh

Code: Select all

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

export MOZILLA_FIVE_HOME=/location/to/thunderbird

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


2.Make the scripts executable with command:

Code: Select all

chmod +x mailto-thunderbird.sh
chmod +x newsto-thunderbird.sh


3. Install mozex (mozex.mozdev.org) in Firefox.
4. From the mozex options set it to intercept mailto and news links and put the following parameters:
mailto :

Code: Select all

/location/to/script/mailto-thunderbird.sh %a %s 

news:

Code: Select all

/location/to/script/newsto-thunderbird.sh %r 


Finished with this one!

Thunderbird to Firefox

1. Copy-paste the following code into the file urlto-firefox.sh

Code: Select all

#!/bin/sh

export MOZILLA_FIVE_HOME=/location/to/firefox

if [ $(ps aux | grep firefox | wc -l) -gt 4 ]; then
# firefox is running
        $MOZILLA_FIVE_HOME/firefox -remote "openURL($1)"
else
#firefox is not running
        $MOZILLA_FIVE_HOME/firefox -P default $1;
fi


2. make it executable with command:

Code: Select all

chmod +x urlto-firefox.sh

3. Edit the prefs.js file in your Thunderbird profile directory and add the following command:

Code: Select all

user_pref("network.protocol-handler.app.http", "/path/to/script/urlto-firefox.sh");


Finished!



These scripts are not completely mine but the base was taking from other scripts as you can see.
Hope it helps you.
ersi
Posts: 4
Joined: August 7th, 2004, 11:15 am

mailto from Opera to Thunderbird

Post by ersi »

These scripts have several editions in the relevant forums. They are very difficult for a novice to get to work. I am a novice, so I went through the process. I tried the scripts for Opera, too, i.e. to launch a mailto-link from Opera to Thunderbird, and made a few discoveries which I would like to share.

First an important note concerning the script: the path to Thunderbird ends in the Thunderbird FOLDER, not the app. I made the annoying mistake of pathing to the app, so the script failed. Nobody says anything about it, so I had to figure it out all by myself. It took time, because I'm a novice, indeed.

First, complete the script. Then, in Opera, choose <em>Preferences, E-mail, Use custom application.</em> There, write the path to the script FILE, not the folder where you've put it. Add <code>%t %s</code>. Note that in Firefox mozex extension you have to write <code>%a</code> instead of <code>%t</code>, but this will result in <code>%a</code> being displayed for receiver's address in Thunderbird, when you launch a mailto-link from Opera to Thunderbird.

This made my Opera and Thunderbird co-operate in Linux, but it has a little annoyance. If the mailto-link has no subject, %s will be displayed for subject. I haven't found a solution to this problem - and I'm not actively working on a solution. So all help is welcome.

Another, more important discovery is, that Opera can launch mailto-links to Thunderbird without any scripts. For custom mail application (in Opera's preferences), write the path to the Thunderbird APP. Add <code>mailto:%t?subject=%s</code>. But it creates one more annoyance in addition to <code>%s</code>-problem -- Thunderbird should be closed when launching the mailto-link. [edit]If it's open, and you press a mailto-link in Opera, Thunderbird will prompt for a new profile.[/edit] So the script is better, though much more difficult.

And here's the script that works for me.

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


<b>Update:</b> write <code>[%t] [%c] [%s]</code> after the path to the script file in Opera preferences, and the %s-for-subject problem will disappear. I found out at the Opera forum, that the brackets are probably needed for bash (any clue what that is?). The <code>%c</code> should make Carbon Copy line work, if present in the mailto-link
ersi
Posts: 4
Joined: August 7th, 2004, 11:15 am

Post by ersi »

Now I have a request. Can someone write a script to launch thunderbird compose window with a browser's page address as the subject? (To make Firefox's Send Page function useful...)
User avatar
beta
Posts: 3
Joined: November 24th, 2004, 10:30 am
Location: Italy
Contact:

ALTERNATIVE SOLUTION

Post by beta »

Hi, I've got an alternative solution that seems to be easier...

THUNDERBIRD: Open with firefox an URL contained in an email

1.Go to the .thunderbird directory in your home directory (it is usually a hidden directory like /home/user/.thunderbird)
2.Go your profile directory (with a random-generated name, like this Xbcgev.default). To be sure u're in the correct directory check if a file named "prefs.js" exists.
3. Create an empty file called "user.js". (If it already exists skip this passage)
4. Open "user.js" and write this line (if the file already exists append the line at the end):
user_pref("network.protocol-handler.app.http", "/usr/bin/firefox/firefox");


/usr/bin/firefox/firefox is obviously the path to execute firefox

5.That's all


FIREFOX: open thunderbird when clicking on a "mailto:" link

1.Go to the .mozilla directory in your home directory (it is usually a hidden directory like /home/user/.mozilla or /home/user/.mozilla/firefox)
2.Go your firefox profile directory (with a random-generated name, like this Xbcgev.default). To be sure u're in the correct directory check if a file named "prefs.js" exists.
3. Create an empty file called "user.js". (If it already exists skip this passage)
4. Open "user.js" and write this line (if the file already exists append the line at the end):

user_pref("network.protocol-handler.app.mailto","/usr/bin/thunderbird/thunderbird");


/usr/bin/thunderird/thunderbird is the path to execute thunderbird

5.That's all

It's really simple and for me it worked perfectly (suse 9.1 personal).
Hope this post could help who, like me, had been googling for hours to find a solution to these problems ;-) Let me know.
Greets :-)
Post Reply