Issue: Clicking on a mailto: link causes the xdg-open dialog to pop up but after approving the action, nothing happens.
Expected: The configured default mail application opens into an email composition window.
Hi everyone,
There are tons of reports of this failure and it has apparently been going on for a long time. I ran into this problem as well. Following googled advice as to checks and solutions yielded no joy.
In trying to track down the problem I was slogging through the moderately complicated xdg-email script. It seemed that things should be working but they were not. However I discovered that there is a hook available that can be used to circumvent the whole issue. You can set up a script named “xdg-email-hook.sh” that overrides the whole xdg-email process.
Now, there are many reasons not to do this but if the drawbacks do not affect you, you might consider this workaround. The drawbacks, at minimum, are:
- The hook feature is probably intended for debugging purposes and could disappear at any time.
- It is a hack
- xdg-email normally provides a lot of functionality besides the simple handling of mailto: links. This workaround probably short circuits all of those.
- xdg-email will now ALWAYS run whatever mail client is set up in the hook script and will IGNORE your xdg-open mime settings for default email handler.
- Did I mention it’s a hack?
- Two years from now you may want to change your xdg-open mailto: default handler, might not remember where and how you put this override in, and wonder why xdg-settings do not work. 'Course you are, like I am, probably wondering that now, but there it is.
Nevertheless it works. I am using this on Ubuntu 22.04 and Thunderbird.
To set up the workaround create a script similar to the following. The script MUST exist
somewhere on your path or it will not work. I put mine in “/usr/local/bin/xdg-email-hook.sh”.
[Edit]: Hmmm. Putting the script in /usr/local/bin will affect everyone on your system. If that is undesirable, a better place might be “$HOME/.local/bin/”. If not already, you would need to add that location to your PATH.
Change the “thunderbird -compose $1” line to something appropriate for your chosen email client.
#!/bin/bash
echo ALERT\: XDG-EMAIL HOOK IN-USE!! To turn off, delete or rename \"$0\"
echo running: thunderbird -compose \"$1\"
thunderbird -compose "$1"
Make the script executable by running:
chmod 755 /path/to/your/xdg-email-hook.sh
Use at your own risk but I hope this alleviates some aggravation for you as it has mine.
Cheers!