Linux.com

Feature

Using Firefox's mozex extension to call an external mail program

By Philip J. Hollenback on October 15, 2004 (8:00:00 AM)

Share Print Comments

I recently moved from Mozilla to Firefox 1.0PR for Web browsing on my Fedora Core 1 Linux desktop system. On that platform, Firefox doesn't do anything with mailto: links by default; it just prints an error message if you click on one. However, a Firefox extension called mozex allows you to use any external mail program for mailto: links in Firefox.
Note that Firefox on Windows does understand mailto: links, and will open the mailer you specify in your Internet Properties control panel. However, if you want to use an arbitrary program that doesn't register with that control panel, mozex works fine on Windows, and gives you other useful features I'll discuss below.

To install mozex, click on the install link while running Firefox. The first time you do this, you will receive a message from Firefox stating that it has blocked software installs from the mozex Web site for security reasons. Click on the warning (at the top of the page) and add the mozex site to your list of approved sites. Then, click on the install link again. Follow the instructions, and mozex will be ready to run after you restart Firefox.

One caveat: mozex has not yet been updated to fully support Firefox version 1.0PR or above. This means that you have to hand-edit your Firefox preferences file before you run it. Quit Firefox, edit the file ~/.mozilla/firefox/<something>.default/prefs.js, and add the following lines to the end:

user_pref("mozex.command.aim", "");
user_pref("mozex.command.download", "");
user_pref("mozex.command.ed2k", "");
user_pref("mozex.command.ftp", "");
user_pref("mozex.command.irc", "");
user_pref("mozex.command.mailer", "/usr/bin/xterm -title mutt -bg black -fg white -e mutt mailto:%A?subject=%S&cc=%C&body=%B");
user_pref("mozex.command.news", "");
user_pref("mozex.command.source", "/usr/bin/xterm -title mutt -bg black -fg white -e /usr/bin/vim %t");
user_pref("mozex.command.telnet", "");
user_pref("mozex.command.textarea", "/usr/bin/xterm -title mutt -bg black -fg white -e /usr/bin/vim %t");
user_pref("mozex.general.tmpdir", "/tmp");
user_pref("mozex.intercept.ftp", false);
user_pref("mozex.intercept.irc", false);
user_pref("mozex.intercept.mailto", true);
user_pref("mozex.intercept.news", false);
user_pref("mozex.universal.command", "");
user_pref("mozex.universal.schemes", "");

The mozex.command.mailer entry is the one responsible for launching your external mail program. In my case, I run mutt in an xterm. You can call any mail program you want. Note that you should specify the full path to the program, and you need to also set mozex.intercept.mail to true.

Now you can run Firefox, click on a mailto: link, and your external mailer pops up. The extra arguments to mozex.command.mailer fill in other optional fields like the subject, cc, and body, so the experience of using an external mail program with Firefox should be exactly the same as using the built-in mailer with Mozilla.

But what about those other preferences, in particular mozex.command.source and mozex.command.textarea? These are also very useful additions to Firefox. The mozex.command.source setting allows you to control what program is used when you right-click on a Web page and choose View Page Source from the mozex menu. My example settings above load the Web page source into the vim text editor, which lets you easily edit and save the HTML source of a page, but you can use any text or HTML editor. Note that if you choose View->Source from the Firefox menu, Firefox will still use its internal source viewer.

I find the mozex support for textareas (config option mozex.command.textarea) possibly even more useful than the support for mailto: URLs. This feature allows you to edit any text input field on a Web page in an external editor. I have always found the text editor built in to Mozilla and Firefox extremely limiting -- for example, there's no way to search for text just in the textarea you are editing. Many Web sites have feedback forms, but you can't easily insert text from another file or check your spelling while editing them.

The textarea support in mozex fixes all this. I have configured mozex to launch vim for textareas. To edit a textarea in an external editor, right-click on the textarea in Firefox. go to the mozex menu, and select Edit Textarea. If this selection is grayed out, that means you clicked on something that wasn't a textarea. If you don't see a mozex menu listed when you right-click on a Web page, you don't have mozex installed.

Mozex will open your editor and load the existing text from the textarea. Make any changes you like. Here's a handy vi hint: use :r /tmp/file.txt to copy the contents of file.txt into your current document. When you are satisfied with your text, save it and exit the editor. You will notice that nothing has changed yet on the Web page in Firefox, which can be a bit confusing. To get Firefox to accept your new text, you must left-click in the textarea once. If you don't do this and attempt to use mozex open the textarea in an external editor again, you will get a message indicating that an editing session is already open.

As you can see from my configuration example, mozex has other settings I haven't touched on here, such as handlers for telnet: and news: URLs. One thing that catches my eye is the universal handler, which allows you to create arbitrary URL schemes. The example script shows how you could use rlogin: or pop: URLs. For instance, you could specify a link rlogin://foo.example.com on a Web page that when clicked would launch an external rlogin program to presumably connect to foo.example.com. While this universal mechanism is probably not that useful on the Internet at large, you could use it to create links to all sorts of custom intranet applications.

The mozex extension illustrates one of the greatest strengths of Firefox: how easy it is to customize. If you are a new Firefox user, spend some time browsing the Firefox extension repository for many other ways to improve your Web browsing experience. There are dozens of useful extensions like mozex out there, and more are appearing all the time.

Share Print Comments

Comments

on Using Firefox's mozex extension to call an external mail program

Note: Comments are owned by the poster. We are not responsible for their content.

Firefox 0.10 opens Evolution on Fedora Core 2

Posted by: Anonymous Coward on October 15, 2004 07:50 PM
If I click a mailto: link on Firefox, it opens Evolution, which is my default mail client on Gnome.

Why doesn't this work for you?

#

Re:Firefox 0.10 opens Evolution on Fedora Core 2

Posted by: Anonymous Coward on October 15, 2004 07:52 PM
Because they're not running Gnome? AFAIK, Firefox will try and use the Gnome default mailer, but if it can't find it it's less sure what to do.

#

Re:Firefox 0.10 opens Evolution on Fedora Core 2

Posted by: Phil Hollenback on October 15, 2004 10:35 PM
That's correct - I don't run Gnome so I did not know that mailto links will launch Evolution in that config.


Still, there are good reasons to use mozex even if your mailto: links already work:


  • Alternate editor for textareas - this is the big one for me, since as I state in the article, I don't like the lack of real editing tools in the default textarea editor.
  • It gives you an alternate 'view source' which you can use to open an editor if you choose.
  • You can pick any program to view source or open mailto: links. This is handy if you like to do things like open a command line mail client (like mutt) in an xterm.

These are the same reasons that mozex is useful on other platforms such as Windows.

#

Re:Firefox 0.10 opens Evolution on Fedora Core 2

Posted by: Anonymous Coward on October 15, 2004 08:51 PM
How about because I have a different default mail client and it still wants to launch evolution?

That is a problem for me.

A Nony Mouse

#

Re:Firefox 0.10 opens Evolution on Fedora Core 2

Posted by: Anonymous Coward on October 17, 2004 05:41 AM
Then configure gnome to use a different default mailer.

It's not a problem for everyone else.

#

Works fine with...

Posted by: Anonymous Coward on October 15, 2004 08:41 PM
...Thunderbird at home and Outlook at work.

#

File : Send Page

Posted by: Anonymous Coward on October 15, 2004 08:54 PM
I have been using this for a good while for mailto links, but it does not change the behaviour of the menu option File : Send Page. That still wants to launch evolution.

If anyone knows how to fix that one without a trip into the source, please let us know.

A Nony Mouse

#

Re:File : Send Page

Posted by: Anonymous Coward on October 15, 2004 09:18 PM
The new firefox has a gconf extension and uses gconf for the default mailer. So i think the way to change would be in gnome setting for default mailer, though i cannot confirm it because i do not have gnome.

#

no need for mozex to achieve this

Posted by: Anonymous Coward on October 15, 2004 10:04 PM
read here for a simple solution

http://www-es.fernuni-hagen.de/~jfh00/blog/040916<nobr>.<wbr></nobr> html

it is german, but the entries for

user.js

are readable anyway

#

Re:no need for mozex to achieve this

Posted by: kc8hr on October 16, 2004 01:13 AM
I prefer Pine which, like mutt, needs a terminal window in X. I found mozex to be tricky to set up in my situation. Here is a similar solution that I found in English:

<A HREF="http://www.wlug.org.nz/MozillaFirefoxNotes" title="wlug.org.nz">http://www.wlug.org.nz/MozillaFirefoxNotes</a wlug.org.nz>

You simply add the following line to prefs.js:

user_pref("network.protocol-handler.app.mailto", "/home//pine.sh");

and save "pine.sh" to your home directory:

#!/bin/bash
xterm -e pine ${1:+-url "$1"}

and you're all set--Firefox and Mozilla open your favorite email client on mailto: links and File > Send Link

Good Luck!
Tim

#

Re:no need for mozex to achieve this

Posted by: Phil Hollenback on October 16, 2004 01:22 AM
That definitely looks like another good way to make Firefox handle mailto: links. If you don't care about any of the other features of mozex, I would say use it.

#

Gmail

Posted by: Anonymous Coward on October 16, 2004 05:04 AM
What I'd like is to be able to specify a webmail account, say Gmail. Have it open a tab, log into the Gmail, and open up a 'Compose' window in that tab, using whatever subject heading supplied by the mailto link. Yep, that's what I'd like.

#

Re:Gmail

Posted by: Curtman on October 16, 2004 01:51 PM
I would very much like to see this too.



Have you tried the <A HREF="http://nexgenmedia.net/extensions/" title="nexgenmedia.net">GMail Notifier</a nexgenmedia.net> extension? Hopefully some day it could be extended to support catching of mailto links somehow.

#

Re:Gmail

Posted by: Anonymous Coward on October 18, 2004 10:53 PM
You should be able to with:

http://www.jedbrown.net/

he has an extension for "Webmail Compose"

#

No need

Posted by: Anonymous Coward on October 16, 2004 05:30 AM
In the current incarnations of Firefox, Thunderbird, and GNOME, one only needs to set one's prefered mail app to Thunderbird and the prefered browser to Firefox. This works without extensions or messing with the JavaScript files.

#

Re:No need

Posted by: Anonymous Coward on October 16, 2004 07:18 AM
Thanks,

this solved my "File : Send Page" question from above. So simple. I had googled a good while back but not come upon this. Ignorance is a royal pain at times.

A Nony Mouse

#

use mozex to launch mozilla thunderbird on windows

Posted by: carmello on October 17, 2004 04:47 AM
Hi,

I changed mozex.command.mailer to

user_pref("mozex.command.mailer", "file:///C:/Program%20Files/Mozilla%20Thunderbird<nobr>/<wbr></nobr> thunderbird.exe mailto:%A?subject=%S&cc=%C&body=%B");

Then I get an error, unrecognized path.
Any ideas ?

#

Re:use mozex to launch mozilla thunderbird on wind

Posted by: Anonymous Coward on October 17, 2004 02:56 PM
1) Install and configure "gconf-editor" which have these settings available (works on KDE also) or 2) install latest version of KDE, which now has the default browser and default mail settings in preferences.

#

Re:use mozex to launch mozilla thunderbird on wind

Posted by: Phil Hollenback on October 18, 2004 05:32 AM
I think you are specifying the path incorrectly. I don't think you need to use the file: url syntax. Try this instead:

<TT>c:/Program%20Files/Mozilla%20Thunderbird/thunderb<nobr>i<wbr></nobr> rd.exe mailto:%A?subject=%S&cc=%C&body=%B</TT>


That's just a guess because I don't use windows.


Note that the newsforge interface appears to be splitting "thunderbird.exe" incorrectly above - remove the space.

#

Anonymous Reader

Posted by: Anonymous Coward on December 08, 2004 04:49 AM
Thanks for explaining how to get mozex working. However, it's better to create a user.js file, in the same directory as the prefs.js file, and edit that. firefox edits the prefs.js file, and if you edit it while firefox is open, you can cause some problems.

-- <A HREF="http://kennethbowen.com/" title="kennethbowen.com">kenneth</a kennethbowen.com>

#

This story has been archived. Comments can no longer be posted.



Tableless layout Validate XHTML 1.0 Strict Validate CSS Powered by Xaraya