vladimiry / ElectronMail

Unofficial ProtonMail Desktop App
GNU General Public License v3.0
1.51k stars 99 forks source link

Option to set app as default mail client #62

Open evangelia1 opened 6 years ago

evangelia1 commented 6 years ago

Hello, I am a tutanota user and I need to make your client the default client in Windows. I have a program that exports images straight to the associated default desktop mail client, so I do not need to first export the images to desktop and then to import them to the desktop client. I use win 7 pro and win 10 home. It seems I can make your app the default client. Please inform.

skewty commented 5 years ago

Same issue. I am not able to set as default app in Linux / Ubuntu / Gnome-shell

heilerich commented 5 years ago

According to this discussion this seems pretty easy to implement, at least on MacOS.

To open a prefilled composer on the protonmail web client you can do this

var injector = window.angular.element(document).injector()

var root = injector.get("$rootScope")
var messageModel = injector.get("messageModel")

let composeWithMessage = (message) => root.$emit("composer.new", { "type": "new", "data": {"message": message} })

let compose = (toAddress, subject, body) => {
    let message = messageModel()
    message.Subject = subject

    message.AutoSaveContacts = 0;
    message.ToList = [{ Address: toAddress, Name: toAddress }]
    message.setDecryptedBody(body)
    composeWithMessage(message)
}

compose("example@example.com", "Testsubjects wanted", "We want your dead body")

Would you be willing to give it a try? Otherwise I could also try to implement this and drop you a PR if you want to, which would probably take some time though.

vladimiry commented 5 years ago

In general, the task consists of two parts:

Would you be willing to give it a try?

I'm not planning to jump into the task yet.

Otherwise I could also try to implement this and drop you a PR if you want to, which would probably take some time though.

As I pointed out adding the feature will increase the maintenance burden. Any web client update could potentially break the functionality so if at least the integration with the web clients code layer will be covered by automated tests then I will accept the PR. Alternatively, if you only need this working on macOS, don't want to deal with tests, etc, you could fork the project, add the change, hook the project up with the CI system and get your own installation package as an outcome.

There also will be an in-between task - showing a list with added to the program accounts, and only having the specific account selected the opening a prefilled composer action will kick in.

heilerich commented 5 years ago

Thanks for the quick reply! I will look into how much effort this will take and reconsider if I am willing to do this for everyone or just me.

Regarding your first point, the registration of the URL scheme, I don't think we need to implement this ourselves (and mess with the Windows Registry and such) as it seems the Electron framework has already taken care of this. There's an API for registering, unregistering and checking default url scheme handlers with the OS.

if at least the integration with the web clients code layer will be covered by automated tests

Could you point me to the sources of the specific tests for the existing web clients for a reference? I searched real quick and couldn't find anything.

Also, would you insist on tutanota support?

vladimiry commented 5 years ago

Electron framework has already taken care of this

I've looked into this topic before. Electron handles the need but the implementation is not complete this is why some hacks expected to be needed.

Could you point me to the sources of the specific tests for the existing web clients for a reference? I searched real quick and couldn't find anything.

There are no tests implemented specifically for preload scripts or web clients. Could be Spectron-based, the example is here. Besides I think, depending on the implementation a custom fixture-like page with prepared web client + app custom/integration logic could be loaded and executed using karma runner.

vladimiry commented 5 years ago

Also, would you insist on tutanota support?

Nope as tutanota support is already deprecated and going to be removed at some point.

vladimiry commented 5 years ago

@heilerich if you will be considering adding a holistic implementation, mailto URL scheme handling would be the starting point. There will be a need to actually verify that it works on Win 7/8/10, Linux (at least Ubuntu recent + Arch) and macOS. This presumably might be a time-consuming task. By the way, Tutanota's desktop app seems to have some hacks for Windows. The remaining stuff I think I could help with or handle completely, including testing.

skewty commented 4 years ago

With the recent rebase onto Electron 9.0.0-beta.5 is has url scheme handling been improved?

vladimiry commented 4 years ago

Nothing new was done in the app code in regard to handling mailto scheme.

bbhtt commented 4 years ago

Same issue. I am not able to set as default app in Linux / Ubuntu / Gnome-shell

It can already handle mailto links on a webpage atleast on Linux this is easier (Arch/Xfce), just not the direct compose box...

ystxn commented 2 years ago

is this still pending changes to electron or considered a will not do?

brcha commented 2 years ago

I would like to see this functioning as well.

vladimiry commented 2 years ago

It's unlikely to come in the near future.

t3dium commented 1 year ago

yeah i agree this'd be a pretty convenient feature to have

bkmo commented 7 months ago

It would be great. The tutanota appimage handles it perfectly. It also works with attachments right from the dolphin file manager.