tutao / tutanota

Tuta is an email service with a strong focus on security and privacy that lets you encrypt emails, contacts and calendar entries on all your devices.
https://tuta.com
GNU General Public License v3.0
6.05k stars 523 forks source link

Not all apps recognise Tutanota as the default mailto application in windows #3574

Closed johnbotris closed 2 years ago

johnbotris commented 3 years ago

We register tutanota as the default mailto by setting the registry keys under HKEY_LOCAL_MACHINE > SOFTWARE > Clients > Mail, but there are other choices like HKEY_CURRENT_USER > SOFTWARE > Clients > Mail. It seems like not all apps check the same key, for example MS Word is always opening in MS Outlook

Update

We decided to change the approach because having two places where we can write registry keys leads to some problems (see #3787). Instead of deciding on HKEY_LOCAL_MACHINE vs HKEY_LOCAL_USER we will always use HKEY_LOCAL_USER to write registry keys (the only reason to not do that is for the admin to set mailto handler for all users but admin has other means to do that should they wish to).

Acceptance criteria

Testing

Two users, A and B

charlag commented 3 years ago

The situation is... complex cc @ganthern https://superuser.com/a/1119010/267277

ganthern commented 3 years ago

this specific case could have been caused by thunderbird not clearing that key when it was deinstalled and word falling back to outlook when it failed to locate the handler.

we still need to look at handling default mail handler differently for a gobally installed tutanota vs a per-user install

macxcool commented 2 years ago

@ganthern Let me know if there's anything you want me to try. I have access to a Windows 10 VM that I can roll back and do things to. I think the Thunderbird angle is a red herring. I have some details on what I've tried in #3602 that @johnbotris closed.

ganthern commented 2 years ago

Hey @macxcool, it's certainly possible that Thunderbird has nothing to do with your problem. There's a number of ways the MAPI can be used to send mail, and we couldn't test all of the applications. This may go too much into detail, but all the apps we tested were happy to just call MAPISendMail and ignore the option to have a session-based interaction. That's why we implemented that function and decided to log calls to the others.

You can find the logs in C:\Users<your username>\AppData\Roaming\tutanota-desktop\logs\mapi.log, It should look like this if Sage actually can't find the dll but others (i.e. the file explorer) can use it:

2021-10-28 | 16:30:45.242 | mapisendmail: parsed message, sending...
2021-10-28 | 16:30:45.254 | make_mailto: mailto:?subject=Emailing%3A%20tutanota_desktop.log&body=Your%20message%20is%20ready%20to%20be%20sent%20with%20the%20following%20file%20or%20link%20attachments%3A%0D%0D%0Atutanota_desktop.log%0A%0D%0D%0D%0ANote%3A%20To%20protect%20against%20computer%20viruses%2C%20e-mail%20programs%20may%20prevent%20sending%20or%20receiving%20certain%20types%20of%20file%20attachments.%20%20Check%20your%20e-mail%20security%20settings%20to%20determine%20how%20attachments%20are%20handled.&attach=C%3A%5CUsers%5Cnig%5CAppData%5CLocal%5CTemp%5Ctutanota%5Cattach%5Ctutanota_desktop.log
2021-10-28 | 16:30:45.266 | send_mail: spawned tutanota client
2021-10-28 | 16:30:45.267 | mapisendmail: sent message!

If there are any lines that contain date | time | mapi*: that are not mapisendmail, Sage probably tries to use some of these other functions and we'll have to implement them.

We'll also reduce the make_mailto: log verbosity while we're at it, that's a little TMI.

Another thing: It could help if you're aware of a free trial for your specific Sage version that we can use to test.

macxcool commented 2 years ago

Thanks @ganthern

OK. I can verify that Thunderbird sets HKCU:\SOFTWARE\Clients\Mail (Default)='Mozilla Thunderbird' and if it isn't at least blanked, right-click -> Send to -> Mail recipient goes to Thunderbird anyway, even if Tutanota is set as the default handler. If that default value is blanked (or set to literally anything ;-) ) the mail is sent via Tutanota.

I did a fresh install of Thuderbird, Tutanota and Sage 50 and Sage isn't sending to Thunderbird either, even when it's the default handler. The same message I posted before happens regardless of what I do. I don't get entries in Tutanota's MAPI log for this.

Man is Windows annoying! This is why I use Linux. The problem is that I recommended that a client purchase a Tutanota subscription and I want to get this working for her and uninstall Thunderbird completely. Thankfully she has an SMTP server still with the same domain name so things are working for now. Sage 50 sends through Thunderbird on her computer, even though I can't get even that working on mine.

macxcool commented 2 years ago

@ganthern Does a dump from Procmon with just calls from Sage during such a MAPI request interest you?

ganthern commented 2 years ago

@ganthern Does a dump from Procmon with just calls from Sage during such a MAPI request interest you?

That would at least be interesting to look at, thank you.

Could you please confirm if you install Tutanota globally or per-user ("only for me")? I may have missed that.

Also, if you want to try other apps, LibreOffice and Adobe Acrobat Reader are also making MAPI calls.

macxcool commented 2 years ago

I installed it globally. Oh. Good. I'll try both of those. Since it's a VM I can easily roll back and try other types of installs too, if you like. This client uses both of those, so it's an interesting test anyway.

ganthern commented 2 years ago

Since it's a VM I can easily roll back and try other types of installs too, if you like.

That would be lovely, the mapi registration in Tutanota doesn't distinguish between global and per-user install currently. Maybe some apps do like to check different keys depending on how the handler is installed.

Man is Windows annoying! This is why I use Linux.

no arguments here ;)

macxcool commented 2 years ago

OK. I have the Sysinternals Process Monitor log here: http://u.pc.cd/Bb2rtalK The password is 'ThisIsAThing'. This is for Sage 50 trying to send an Invoice via MAPI. I tried to make the capture as narrow as possible.

macxcool commented 2 years ago

Adobe Reader says: "There is no email program associated to perform the requested action" when I've blanked or whatevered that registry key. If the key says 'Mozilla Thunderbird' it works with Thunderbird even though Tutanota is registered and set as the Default handler. http://u.pc.cd/466 same password.

macxcool commented 2 years ago

BTW, I tried setting that registry key to all kinds of things, like 'Tutanota', 'tutanota' (not that Windows cares about case), 'Tutanota Desktop', etc. Nothing seemed to make a difference.

macxcool commented 2 years ago

Libreoffice does work without that key. Nice!

2021-10-28 | 13:44:06.009 | mapisendmail: parsed message, sending...
2021-10-28 | 13:44:06.013 | make_mailto: mailto:?subject=noname&attach=C%3A%5CUsers%5CTV45057%5CAppData%5CLocal%5CTemp%5Ctutanota%5Cattach%5Cnoname.odt
2021-10-28 | 13:44:06.074 | send_mail: spawned tutanota client
2021-10-28 | 13:44:06.075 | mapisendmail: sent message!

If the key is set to 'Mozilla Thunderbird', though, the mail goes through Thunderbird. I think we need to at least blank that key or check to see if it exists or the Default is set to 'Mozilla Thunderbird'.

ganthern commented 2 years ago

okay, seems like we need to be more judicious in applying the registry keys.

again, thank you for your effort!

ganthern commented 2 years ago

So, in my tests, the demo version of Sage50 seems to be OK with a per-user install and a global install of tutanota in a fresh Win10 VM (if it doesn't choke on date formats and refuses to run at all).

I'll test this again with a system that has been "tainted" by thunderbird, but so far I can't see a fundamental problem.

ganthern commented 2 years ago

The registry entries for registering as a mail handler should be a little more well-behaved with https://github.com/tutao/tutanota/pull/3715

Testing

on a fresh windows machine with two users A and B: install tutanota desktop for A per-user and register/set it as the default mail handler, then check:

unregister, then uninstall tutanota and then reinstall per-machine

macxcool commented 2 years ago

Will do. Probably tomorrow.

ganthern commented 2 years ago

@macxcool, the checklist is part of our testing processes for the next release. It would be better to wait for the PR being merged, since this one depends on another PR in a different repo.

sarashub commented 2 years ago

MAPI is not working for local install (windows 10)

charlag commented 2 years ago

We discovered that it is somehow related to the .dll built on Windows machine. .dll built via Wine is bigger but works.

charlag commented 2 years ago

Should be fixed by depending on this release: https://github.com/tutao/mapirs/releases/tag/mapirs-release-0.4.0

charlag commented 2 years ago

Clean global install, attempt to register:

Stacktrace:
Error: EPERM: operation not permitted, open 'C:\Program Files\test Tutanota Desktop\99dc225701c4bd5289ae99e7'

it seems like we still need to elevate permission to register when it's a global

ganthern commented 2 years ago

Clean global install, attempt to register:

Stacktrace:
Error: EPERM: operation not permitted, open 'C:\Program Files\test Tutanota Desktop\99dc225701c4bd5289ae99e7'

it seems like we still need to elevate permission to register when it's a global

This is happening because the client tries to write the registry script it needs to execute into its execPath, which is in C:/Program Files for global installs and read-only for normal users.

Putting it into the tutanota tmp directory should fix this.

johnbotris commented 2 years ago

Documents sent from applications such as LibreOffice aren't being attached