4

To run the default web browser or terminal there are commands like x-www-browser and x-terminal-emulator. There are other alternatives for common programs.

Is there a similar command to run the default email client?

As an alternative, is there a way to execute the mailto protocol handler?

2 Answers 2

5

You can open the default email client, but with a new message window open with this commands:

xdg-email

or

xdg-open mailto://

Both support some options to compose the new message or a standard mailto url. xdg-email also supports attachments, cc and bcc fields.

gnome-open mailto://

Will also work, but it's only supported under gnome.

7
  • So there is no way to open just the client and not a new message window as well?
    – Mat
    Feb 6, 2012 at 17:54
  • Not that I know. You can check the xdg-email source, it's a bash script. It basically finds the .desktop file associated with "x-scheme-handler/mailto", and from it extracts the binary. Feb 6, 2012 at 18:38
  • Not looking likely unless I rewrite it. It also seems the solution differs depending on the distro... But I haven't looked in too much detail as it can't do what I want. Opening with the message window is sufficient (though not ideal) so unless there is a miracle solution this would seem to be the answer.
    – Mat
    Feb 6, 2012 at 19:05
  • xdg-open is a standard, and at least it works in Ubuntu, Arch and Fedora. I believe that it will likely work in most distributions. Feb 7, 2012 at 7:46
  • 1
    In any event, xdg-email is the best way to go. Thanks for the answer.
    – Mat
    Feb 7, 2012 at 15:56
1

I took the relevant function from xdg-email, added some explanatory comments, and made some tweaks. The result does what OP needed--simply launches default email client. Four years too late, perhaps, but better late than never.

http://pastebin.com/WuEMAJh9

1
  • Adding your code inline is recommended, in case the link gets destroyed or lost.
    – theGtknerd
    May 31, 2022 at 20:00

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .