Bug 292606 - Setting a custom mail client has no effect on mailto
Summary: Setting a custom mail client has no effect on mailto
Status: RESOLVED FIXED
Alias: None
Product: systemsettings
Classification: Applications
Component: kcm_componentchooser (show other bugs)
Version: 4.9.0
Platform: openSUSE Linux
: HI major
Target Milestone: ---
Assignee: Unassigned bugs mailing-list
URL:
Keywords: reproducible, usability
: 360073 369394 373993 379901 398246 400608 405374 410278 411242 (view as bug list)
Depends on:
Blocks:
 
Reported: 2012-01-27 16:39 UTC by Christopher Yeleighton
Modified: 2020-01-22 16:21 UTC (History)
23 users (show)

See Also:
Latest Commit:
Version Fixed In: 5.19.0


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Christopher Yeleighton 2012-01-27 16:39:26 UTC
Version:           unspecified (using KDE 4.7.2) 
OS:                Linux

The setting of the mail client has no effect on the application handling mailto URL.

Reproducible: Always

Steps to Reproduce:
  1. Tell Component Chooser to set mail client to mailx '%t' in terminal.
  2. Tell KRunner to launch URL 'mailto:bugzilla_noreply@kde.org'

Actual Results:  
  2. Launch with kmail -caption "%c"

Expected Results:  
  2. Launch with mailx '%t'

OS: Linux (x86_64) release 3.1.0-1.2-desktop
Compiler: gcc

Note: This setting affects only raw e-mail addresses automatically recognised in KDE text viewer (such as Konversation).
Comment 1 Christoph Lange 2012-10-03 10:23:40 UTC
Same here. Interestingly the mail client setting in the component chooser is respected when I run

xdg-email mailto:bugzilla_noreply@kde.org

but it is not respected by KRunner, Konqueror, nor by xdg-open.
Comment 2 Jekyll Wu 2012-10-03 11:12:21 UTC
I can confirm the issue in comment #1 is easy to reproduce in KDE SC 4.9
Comment 3 Christoph Lange 2012-10-03 11:17:32 UTC
(In reply to comment #2)
> I can confirm the issue in comment #1 is easy to reproduce in KDE SC 4.9

Indeed even 4.9.1. Sorry, forgot to report the version in my previous comment.
Comment 4 Jiri Slaby 2014-05-12 09:24:23 UTC
This is still the case in 3.12.4.
xdg-open/kde-open mailto:x@y.com still does not open the preferred application. According to strace of the process I see:
execve("/usr/bin/thunderbird", ["/usr/bin/thunderbird", "%s", ""], [/* 95 vars */]) = 0

Where does this come from? I have set %u in the system settings... And why is not the string %s replaced by subject?

The command used:
strace -fe execve kde-open mailto:x@y.com
Comment 5 Jiri Slaby 2014-05-12 09:25:19 UTC
Turning on debug just shows this:
unnamed app(1501) ClientApp::doIt: Creating ClientApp
kioclient(1501) ClientApp::kde_open: KUrl("mailto:x@y.com")
kioclient(1501)/kio (KRun) KRun::slotTimeout: KRun(0x1eee590)  slotTimeout called
kioclient(1501)/kio (KRun) KRun::init: INIT called
kioclient(1501)/kdecore (KSycoca) KSycocaPrivate::openDatabase: Trying to open ksycoca from "/var/tmp/kdecache-xslaby/ksycoca4"
kioclient(1501)/kio (KRun) KRun::init: Helper protocol
kioclient(1501)/kfile (kdelibs) KRecentDocument::add: KRecentDocument::add for  "mailto:x@y.com"
kioclient(1501)/kio (KRun) runTempService: runTempService: first url  "mailto:x@y.com"
kioclient(1501)/kio (KRun) runTempService: runTempService: KProcess args= ("/usr/bin/thunderbird", "%s", "")
kioclient(1501)/kdecore (KStartupInfo) KStartupInfo::createNewStartupId: creating:  "anemoi;1399886695;787775;1501_TIME0" : ""
kioclient(1501)/kdecore (KStartupInfo) KStartupInfo::sendStartup: sending  "new:  ID="anemoi;1399886695;787775;1501_TIME0"   BIN="thunderbird" DESCRIPTION="Spouštím " DESKTOP=2 WMCLASS="0" HOSTNAME=anemoi NAME="thunderbird" SCREEN=0"
kioclient(1501)/kdecore (KStartupInfo) KStartupInfo::sendChange: sending  "change:  ID="anemoi;1399886695;787775;1501_TIME0"   PID=1504"
kioclient(1501)/kio (KRun) KRun::slotTimeout: KRun(0x1eee590)  slotTimeout called

(process:1504): GLib-CRITICAL **: g_slice_set_config: assertion 'sys_page_size == 0' failed
kioclient(1501)/kio (KRun) KProcessRunner::slotProcessExited: "/usr/bin/thunderbird" exitCode= 0 exitStatus= 0
kioclient(1501)/kdecore (KStartupInfo) KStartupInfo::sendFinish: sending  "remove:  ID="anemoi;1399886695;787775;1501_TIME0"   HOSTNAME=anemoi PID=1504"
Comment 6 Thiago Jung Bauermann 2014-12-11 23:32:43 UTC
I had the same problem. It was set to evolution, which I don't have installed (haven't used it in years).

Very annoying since because of this bug KMail tries to launch evolution when using the mailing list options in the menu, such as Message → Mailing list → Unsubscribe (email).

I found out that I had the following entries in ~/.local/share/applications/mimeapps.list:

x-scheme-handler/mailto=userapp-Evolution-8XCMWV.desktop;
x-scheme-handler/mailto=userapp-Evolution-8XCMWV.desktop

I have that file in the same directory:

hactar·⚡ cat ~/.local/share/applications/userapp-Evolution-8XCMWV.desktop

[Desktop Entry]
Encoding=UTF-8
Version=1.0
Type=Application
Exec=evolution --component=mail %u
Name=Evolution
Comment=Custom definition for Evolution
NoDisplay=true

After removing the x-scheme-handler lines from mimeapps.list, it finally works!
Comment 7 Jiri Slaby 2015-01-04 13:55:27 UTC
(In reply to Thiago Jung Bauermann from comment #6)
> After removing the x-scheme-handler lines from mimeapps.list, it finally
> works!

Yes, it indeed does. Thanks a lot!
Comment 8 Tristan Miller 2016-10-06 20:40:55 UTC
Confirming this bug still exists in System Settings 5.7.4.  The e-mail client I specify isn't launched when I follow a link to a mailto: URL from an application.  Contrary to Comment #1, xdg-email also doesn't launch the correct e-mail client.  xdg-open and kde-open also don't work correctly for mailto: URLs.
Comment 9 Tristan Miller 2016-10-06 20:57:44 UTC
Jiri, how did you "turn on debug" to get the output you posted in Comment #5?  I would like to try the same thing.

In the meantime, does anyone have a workaround?
Comment 10 Jiri Slaby 2016-10-07 05:58:35 UTC
(In reply to Tristan Miller from comment #9)
> Jiri, how did you "turn on debug" to get the output you posted in Comment
> #5?  I would like to try the same thing.

Via kdebugdialog.
Comment 11 Tristan Miller 2016-10-09 14:51:28 UTC
After logging out and back in again, xdg-email and xdg-open now work properly.  However, kde-open still opens mailto: URLs in KMail.  Turning on all debugging output via kdebugdialog shows kioclient attempting to launch KMail, not the third-party e-mail program I specified in System Settings:

$ kde-open mailto:x@y.com
unnamed app(1503) ClientApp::doIt: Creating ClientApp
kioclient(1503) ClientApp::kde_open: KUrl("mailto:x@y.com")
kioclient(1503)/kio (KRun) KRun::slotTimeout: KRun(0x1714430)  slotTimeout called
kioclient(1503)/kio (KRun) KRun::init: INIT called
kioclient(1503)/kdecore (KSycoca) KSycocaPrivate::openDatabase: Trying to open ksycoca from "/var/tmp/kdecache-psy/ksycoca4"
kioclient(1503)/kio (KRun) KRun::init: Helper protocol
kioclient(1503)/kfile (kdelibs) KRecentDocument::add: KRecentDocument::add for  "mailto:x@y.com"
kioclient(1503)/kio (KRun) runTempService: runTempService: first url  "mailto:x@y.com"
kioclient(1503)/kio (KRun) supportedProtocols: supportedProtocols: ("KIO")
kioclient(1503)/kio (KRun) runTempService: runTempService: KProcess args= ("/usr/bin/kmail", "-qwindowtitle", "", "mailto:x@y.com")
kioclient(1503)/kdecore (KStartupInfo) KStartupInfo::createNewStartupId: creating:  "ferret.nothingisreal.com;1476024386;317165;1503_TIME0" : ""
kioclient(1503)/kdecore (KStartupInfo) KStartupInfo::sendStartup: sending  "new:  ID="ferret.nothingisreal.com;1476024386;317165;1503_TIME0"   BIN="kmail" DESCRIPTION="Launching " DESKTOP=0 WMCLASS="0" HOSTNAME=ferret.nothingisreal.com NAME="kmail" SCREEN=0"
kioclient(1503)/kdecore (KStartupInfo) KStartupInfo::sendChange: sending  "change:  ID="ferret.nothingisreal.com;1476024386;317165;1503_TIME0"   PID=1505"
kioclient(1503)/kio (KRun) KRun::slotTimeout: KRun(0x1714430)  slotTimeout called
Comment 12 Tristan Miller 2017-04-24 19:52:35 UTC
Problem still exists with System Settings 5.9.4.
Comment 13 Nate Graham 2018-11-26 05:44:54 UTC

*** This bug has been marked as a duplicate of bug 360073 ***
Comment 14 Nate Graham 2018-11-27 00:36:08 UTC
*** Bug 360073 has been marked as a duplicate of this bug. ***
Comment 15 Nate Graham 2018-11-27 00:36:13 UTC
*** Bug 369394 has been marked as a duplicate of this bug. ***
Comment 16 Nate Graham 2018-11-27 00:36:17 UTC
*** Bug 373993 has been marked as a duplicate of this bug. ***
Comment 17 Nate Graham 2018-11-27 00:36:22 UTC
*** Bug 379901 has been marked as a duplicate of this bug. ***
Comment 18 Nate Graham 2018-11-27 00:36:27 UTC
*** Bug 398246 has been marked as a duplicate of this bug. ***
Comment 19 Nate Graham 2018-11-27 00:36:33 UTC
*** Bug 400608 has been marked as a duplicate of this bug. ***
Comment 20 Nate Graham 2018-11-27 04:11:23 UTC
Unlike Bug 350663, this one seems a lot tricker. Here are the results of my investigation tonight:

Selecting "Use different email client" in the KCM and entering some text there results in ~/.config/emaildefaults being updated: it adds or updates EmailClient[$e]=<the text you entered>. This is very reliable and happens 100% of the time.

This ~/.config/emaildefaults file seems to be something KDE-specific: https://cgit.kde.org/kconfig.git/tree/src/core/kemailsettings.cpp#n228. It appears to be read in only one place: https://cgit.kde.org/kservice.git/tree/src/kdeinit/ktoolinvocation_x11.cpp#n132, but that invokeMailer function is used all over the place: https://lxr.kde.org/search?_filestring=&_string=invokeMailer

However, somehow nothing set in that file actually seems to be getting used; mailto: links totally ignore it.

~/.config/mimeapps.list also stores information on the default mailto: handler. The [Default Applications] section always seems to have x-scheme-handler/mailto=org.kde.kmail.desktop;. This can be overridden in the [Added Associations] section. Mine has x-scheme-handler/mailto=thunderbird.desktop; in there. It seems that Thunderbird added itself there when it asked whether or not it could be the default email client and was told yes. The config data stored there seems to take precedence over ~/.config/emaildefaults.

This feels fragile. Conceptually, it seems like we might want to deprecate ~/.config/emaildefaults and just rely on ~/.config/mimeapps.list, which is a cross-desktop standard. All the functionality is still there via the apps' desktop files. Also, when an app implements its own "do you want to make me the default program?" UI, it will update the shared config data so the KCM can update its own UI display automatically, rather than the two drifting out of sync and making the KCM inaccurate, which is what's happened here.

Does any of this make sense? I'd very much appreciate if someone of a more veteran KDE tenure could let me know if I'm on the right or wrong track here. I CCd a bunch of you, hope you don't mind!
Comment 21 Nate Graham 2018-12-23 04:21:44 UTC
Probably needs something similar to what I did in https://phabricator.kde.org/D17371
Comment 22 Patrick Silva 2019-03-26 15:54:34 UTC
*** Bug 405374 has been marked as a duplicate of this bug. ***
Comment 23 Nate Graham 2019-08-04 23:51:00 UTC
*** Bug 410278 has been marked as a duplicate of this bug. ***
Comment 24 Nate Graham 2019-08-24 13:36:41 UTC
*** Bug 411242 has been marked as a duplicate of this bug. ***
Comment 25 Méven Car 2020-01-10 13:12:37 UTC
I completely agree with you Nate : we should deprecate (if not completely remove) ~/.config/emaildefaults and use only ~/.config/mimeapps.list to store the default mail client and probably Deprecate/Remove KEMailSettings at term. It is used in componentchooser, takstools.cpp and KMail.

I had a look at the latest duplicated bugs, and it is a mixed bag:

 - The original bug was about mailto support in KRunner only using kmail. I believe krunner has had no support for mailto for some time. Probably around the time of 2016-04-22 "Remove kmailservice5, it can only do harm at this point." https://cgit.kde.org/kio.git/commit/?id=2e6980e9ba3b91798dad0db9f9d78317b2d7e4a2 . And this will need to get fixed.

 - Some are about "Send via Email" not using the set default application. It seems to work in master at least, but lack working "attach file" with any other email client than kmail. I am afraid we would need specific code for each email client, gnome handles this via scripts : https://ubuntuswitch.wordpress.com/2007/07/09/howto-use-mozilla-thunderbird-in-nautilus-send-to-instead-of-evolution-for-attachments/

 - https://bugs.kde.org/show_bug.cgi?id=411242 https://bugs.kde.org/show_bug.cgi?id=410278 are about the componentchooser UI not working properly : I am working on it. I'd like to simplify the UI to only allow to select applications with a desktop file associated with the mimetype "x-scheme-handler/mailto", sort of like we do for the browser chooser since https://phabricator.kde.org/D26100 with "x-scheme-handler/http"/"x-scheme-handler/https" (as does gnome https://gitlab.gnome.org/GNOME/gnome-control-center/blob/master/panels/default-apps/cc-default-apps-panel.c#L155). There is a first patch https://phabricator.kde.org/D26559 that will update the cached email client and make the setting instantly taken into account.
Comment 26 Nate Graham 2020-01-22 16:21:01 UTC
This was just fixed for Plasma 5.19!