Ever click on a mailto: link, only to scream in frustration as Apple Mail opens yet again? The curse of the webmail user is that there is no way to get around this problem. That is, until now.
Webmailer is an unoriginally named program (actually a preference pane) for Mac OS X that allows you to fix this problem. You can set it to open any URL or run any shell script, complete with the parameters lifted from the mailto link.
Webmailer comes with several preset configurations for popular webmail systems. If you're using one of those, select it and click "Choose". Alternately, double-click next to your row in the column that displays which configuration is active. The green indicator should move to the row you want. If you are using a webmail program (e.g. SquirrelMail as opposed to Yahoo! Mail), you will need to change anything in CAPITAL LETTERS to match your actual mail website. You can find out what it should be by logging in to your mail and examining the URL.
If, on a certain occasion, you want to choose a different configuration from your default, just hold down the shift key when you click the mailto link. (If your browser takes a different action when the shift key is pressed, just click first and then hold the shift key.)
By default, Webmailer attempts to guess which browser to use to open your webmail program. If you want Webmailer to always use your default browser, you can check the "always use default browser" option in the preferences pane.
If none of the default configurations match your webmail, you can make a new one by clicking the "Add" button. Enter a name, then press Tab to edit the destination field. This should generally be a URL, likely directed at the Compose page on your webmail site. You can use the following placeholders anywhere in the URL string; they'll be replaced with the appropriate parameters from the mailto link. (Keep in mind that your webmail site may not support all of them).
You can also use the following modifying forms. The word "to" here is merely an example; any parameter including ? will work.
URLs do have some reserved characters; if you want to put one of them in you should probably escape them using percent syntax. Note that this is only for characters in the literal URL; most of the time these don't matter for the parameters.
Good luck!
If you prefer, you can use a shell script instead of a URL — for example, to log all URLs you click on. (Why you'd want to do this is another story, but there are command-line-based mail programs). Anything that doesn't create a valid URL will be interpreted as a shell script and run in the Terminal. All parameters are still supported, and URL encoding is unnecessary. However, any quotes in the URL are automatically URL-encoded, so that quotes in your shell script will work as expected. It is suggested that you use single quotes around any placeholders in your script.
"But wait," you say, "I just wanted to log everything to a file. I didn't want to open the Terminal for that." That's easy. Just add a # to the very beginning of the line. (This would be interpreted as "comment" in most shells, so it won't make any commands impossible to run). The resulting command, which might look something like this: "#echo [to] >> ~/mailto.txt", will run without the Terminal opening at all.
If you just want to open a file or application (as if you had clicked on it in the Finder) you can either use a file URL:
file:///Applications/Mail.app
or a shell script:
open /Applications/Mail.app
But neither one will allow you to pass parameters to the program or file, so it's a lot less useful than it might seem. Instead, you can use an AppleScript to pass parameters to a given app:
#osascript -e 'tell application "Mail"' -e 'GetURL "mailto:[to]?[?]"' -e 'activate' -e 'end tell'
But if you were actually going to use Mail, you wouldn't have downloaded Webmailer, right?
If you want to uninstall Webmailer (for whatever reason), just control-click its icon in the "Show All" view of System Preferences and choose to remove it. The default mail handler should revert to Apple Mail; if it doesn't, try emptying the Trash (where the preference pane usually ends up).
webmailer@belkadan.com: Bugs, requests, questions, new destination URLs? E-mail me!
belkadan.com: Get more great programs from Belkadan Software!
Copyright © 2011 Jordy Rose