the-djmaze / snappymail

Simple, modern & fast web-based email client
https://snappymail.eu
GNU Affero General Public License v3.0
1.01k stars 121 forks source link

First-class support for Nextcloud #96

Closed pemocarlo closed 1 year ago

pemocarlo commented 3 years ago

Firt of all, thank you for this rewrite of the Rainloop app, it is really needed.

After reading the documentation, I saw that you removed support for all 3rd party apps, to ensure GDPR compliance. But I wanted to know if you would be open to support Nextcloud - as an open source project where you are guaranteed to have control of your data, this should make sense.

Thanks a lot for your consideration

Is your feature request related to a problem? Please describe. I have been using Rainloop with Nextcloud. In my opinion, it is the best email option available. Nevertheless, the integration between the two is currently less than perfect.

Describe the solution you'd like Have a better integration with Nextcloud

Describe alternatives you've considered Modify the Rainloop app to improve this, but the code is a bit outdated. I would prefer to work with this fork :)

Additional context There is currently a Rainloop app for Nextcloud: https://github.com/pierre-alain-b/rainloop-nextcloud Adding attachments from Nextcloud: https://github.com/RainLoop/rainloop-webmail/issues/2023

UPDATE 2022 It's alive at https://apps.nextcloud.com/apps/snappymail

the-djmaze commented 3 years ago

Firt of all, thank you for this rewrite of the Rainloop app, it is really needed.

Thanks for the heads up

Is your feature request related to a problem? Please describe. I have been using Rainloop with Nextcloud. In my opinion, it is the best email option available. Nevertheless, the integration between the two is currently less than perfect.

Describe the solution you'd like Have a better integration with Nextcloud

Well, that's the problem. I have no time to make a better integration (maybe someone else does). So why have a half-baked integration? It's easier to have a standalone webmail and a link in Nextcloud to it. Because when it's integrated, people will request features and someone has to create them, like:

Mer0me commented 3 years ago

We're about to switch 600 users from Exchange/Outlook to Nextcloud/rainloop, but a snappymail Nextcloud app should be greater. Is it complicated to reproduce the rainloop-nextcloud app with SnappyMail ?

pemocarlo commented 3 years ago

@the-djmaze Thank you for your reply!

I completely agree with you that having a half-baked integration is not ideal. I guess that a Nextcloud integration fits better in a plugin. I might give it a try, but I am kind of a beginner. Do you have some basic instructions on how to create a development environment for snappy mail?

the-djmaze commented 3 years ago

I might give it a try, but I am kind of a beginner.

For that i've started a branch named OwnCloud https://github.com/the-djmaze/snappymail/tree/OwnCloud In there i made some changes to the source and a plugin. https://github.com/the-djmaze/snappymail/commit/6e26c767c31b6edb51a6393155db13a3f20c66f9

Do you have some basic instructions on how to create a development environment for snappy mail?

Read https://github.com/the-djmaze/snappymail/blob/master/CONTRIBUTING.md Then git checkout OwnCloud

And get https://apps.nextcloud.com/apps/rainloop as example

the-djmaze commented 3 years ago

P.S. i've downloaded it and see that owncloud is different from nextcloud these days.

I will wrap up some basic code so you have a better start.

pemocarlo commented 3 years ago

Thanks for this!

P.S. i've downloaded it and see that owncloud is different from nextcloud these days.

Yes, indeed, Nextcloud is a fork of Owncloud, which started back in 2016. I guess they still share most of the code base, but they will definitely continue diverging

Rainloop mail has some default options to add attachments to owncloud, dropbox, etc. I haven't tried snappy mail yet, but from what I've read, you removed all the related code.

In that case, do you think about adding something similar, in this case to Nextcloud, but better as a plugin?

the-djmaze commented 3 years ago

but better as a plugin?

@carlosperezm i've modified and put the NextCloud code of pierre alain in the branch. You can start with that to make the plugin and integration better. The plugin is in /plugins/nextcloud

Mer0me commented 3 years ago

If I can make 3 wishes to developers of Snappymail/Nextcloud app(s) :

That would be awesome !

Mer0me commented 3 years ago

I've forgotten a 4th wish : be able to insert .ics attachments in the Nextcloud calendar !

scubamuc commented 3 years ago

@the-djmaze

nextcloud integration plans is great news! thank you for your fantastic work!

the-djmaze commented 3 years ago

The code is merged into master https://github.com/the-djmaze/snappymail/tree/master/integrations/nextcloud/snappymail

You can use that to further develop the integration. I can't because i don't have NextCloud nor OwnCloud

the-djmaze commented 3 years ago

I've installed NextCloud 22.1 locally to see if i can do something. First i need to report something to them thru HacherOne

webagroprom commented 3 years ago

Any news on nextcloud rainloop integration with add attachments feature? Thanks.

Mer0me commented 3 years ago

Work in progress here : we were able to add a button into the compose window and, using the Nextcloud Filepicker project, it opens a dialog box where we can select one or more files in Nextcloud and generate and copy the link(s) in the message body. TO DO : authenticate the nextcloud user with oauth2 (auth is hardcoded for now)

Stay tuned !

the-djmaze commented 2 years ago

@Mer0me

TO DO : authenticate the nextcloud user with oauth2 (auth is hardcoded for now)

I've modified the way how Login() on SMTP, IMAP & Sieve are processed. And added SASL support for OAUTHBEARER (RFC 7628) and the old XOAUTH2.

Example plugin code mockup for v2.8+:

<?php

class LoginOAuth2Plugin extends \RainLoop\Plugins\AbstractPlugin
{
    const
        NAME     = 'OAuth2',
        VERSION  = '1.0',
        RELEASE  = '2021-10-22',
        REQUIRED = '2.8.0',
        CATEGORY = 'Login',
        DESCRIPTION = 'IMAP, Sieve & SMTP login using OAuth2';

    public function Init() : void
    {
        $this->UseLangs(true);
        $this->addJs('LoginOAuth2.js');
        $this->addHook('imap.before-login', 'ImapLogin');
//      $this->addHook('smtp.before-login', array($this, $oSmtpClient, &$aCredentials));
//      $this->addHook('sieve.before-login', array($this, $oSieveClient, &$aCredentials));
    }

    public function ImapLogin(\RainLoop\Model\Account $oAccount, \MailSo\Imap\ImapClient $oImapClient, array &$aCredentials) : void
    {
        $sPassword = $aCredentials['Password'];
        $aTokens = \json_decode($sPassword);
        $sAccessToken = !empty($aTokens[0]) ? $aTokens[0] : '';
        $sRefreshToken = !empty($aTokens[1]) ? $aTokens[1] : '';
        if ($sAccessToken && $sRefreshToken) {
            $aCredentials['Password'] = $this->refreshTokenCallback($sAccessToken, $sRefreshToken);
            $aCredentials['UseAuthOAuth2IfSupported'] = true;
        }
    }
}

P.S. And LoginOAuth2.js mockup code

(rl => {
    if (rl) {
        addEventListener('rl-view-model', e => {
            if (e.detail && 'Login' === e.detail.viewModelTemplateID) {
                const LoginUserView = e.detail,
                    submitCommand = LoginUserView.submitCommand;
                LoginUserView.submitCommand = (self, event) => {
                    if (LoginUserView.email().includes('@gmail.com')) {
                        // TODO: redirect to OAuth URI
                    } else {
                        submitCommand.call(LoginUserView, self, event);
                    }
                };
            }
        });
    }

})(window.rl);
cm-schl commented 2 years ago

Hi,

I'm sorry but am I right that at the moment the Nextcloud integration isn't officially available?

scubamuc commented 2 years ago

yip, that is correct. consider it work in progress... the community is doing excellent work, so you'll have to be patient if you can't contribute.

the-djmaze commented 2 years ago

And someone else also seems to be working on the file picker #307

HeyVern commented 2 years ago

@the-djmaze I am very excited about a Snappymail integration with Nextcloud. I'd be happy to help with testing. Is this thread the best place to discuss the project?

husim0 commented 2 years ago

I would be very happy too to test it :) Rainloop is very good and "well integrated" with Nextcloud, but Snappy seems far better and modern !

DragoBarny commented 2 years ago

Hello, I'm sorry but I don't see the snappymail package in the nextcloud (24.0.3) apps library I copied snappymal's git to nextcloud's app directory (old fashioned way) and the app appears (icon and config) but if I click on the administration link I just have a 'null' message that is displayed

beankylla commented 2 years ago

What can a non-code do to help ? :)

schengawegga commented 2 years ago

What can a non-code do to help ? :)

Hello, I'm sorry but I don't see the snappymail package in the nextcloud (24.0.3) apps library I copied snappymal's git to nextcloud's app directory (old fashioned way) and the app appears (icon and config) but if I click on the administration link I just have a 'null' message that is displayed

Iยดve got the same problem. Snappymail is not in the app library (NC 24.0.2) and after copying snappymail manually in the app directory and activating, only gives a "null" response on the app site and the admin site.

the-djmaze commented 2 years ago

I've added a plugin named nextcloud. It should give people a start for integration plugins. You can find it at https://github.com/the-djmaze/snappymail/tree/master/plugins/nextcloud

the-djmaze commented 2 years ago

I've changed the Nextcloud example code to be v18+ compatible and use better security. Now the stored passwords use the SnappyMail Crypt class to properly encrypt the login password.

I could not test the code yet, as i have just setup a Nextcloud with error This version of Nextcloud is not compatible with PHP>=8.2.

szaimen commented 2 years ago

I could not test the code yet, as i have just setup a Nextcloud with error This version of Nextcloud is not compatible with PHP>=8.2.

You could try https://github.com/nextcloud/all-in-one#nextcloud-all-in-one which shouldn't have this issue.

For a local only version see this: https://github.com/nextcloud/all-in-one/discussions/588#discussioncomment-3450343

--

For a more complete dev instance see this: https://help.nextcloud.com/t/tutorial-how-to-set-up-a-nextcloud-development-environment-on-mac-or-ubuntu/145462

the-djmaze commented 2 years ago

The base code is working now. afbeelding

It uses secure encrypted SSO to login instead of the old RainLoop insecure code. I urge anyone who is working on an integration to carefully look at my new code!

the-djmaze commented 2 years ago

Feel free to try/test:

https://github.com/the-djmaze/snappymail/releases/tag/v2.18.6

pierre-alain-b commented 2 years ago

Excellent, I will test soon!

the-djmaze commented 2 years ago

https://github.com/the-djmaze/snappymail/releases/tag/v2.18.6

the-djmaze commented 2 years ago

The embedded mode (without iframe) should work, but the CSS is a bit weird: afbeelding

vs original afbeelding

the-djmaze commented 2 years ago

Most things are fixed now for embed mode. Currently i found 1 annoying bug with it: ServiceWorker Notifications not supported

the-djmaze commented 2 years ago

@Mer0me see the bottom message menu option for next plugin release ;) afbeelding

Mer0me commented 2 years ago

That's unfair :p Just when we decide to use Nextcloud Mail ! I will keep an eye on snappy evolution... The killing feature of Nextcloud Mail is unified search. Not sure snappy will be able to achieve this... But for now Nextcloud Mail cannot save entire .eml into the cloud :( Only attachments...

cm-schl commented 2 years ago

That's unfair :p Just when we decide to use Nextcloud Mail ! I will keep an eye on snappy evolution... The killing feature of Nextcloud Mail is unified search. Not sure snappy will be able to achieve this... But for now Nextcloud Mail cannot save entire .eml into the cloud :( Only attachments...

Be aware that at the moment Nextcloud Mail is not able to search full text etc.: https://github.com/nextcloud/mail/issues/5611

Maybe there is some progress in the future on IMAP search but at the moment it seems that "only" (that is already some giant leap) a search on the DB is possible with https://github.com/nextcloud/mail/pull/6546

the-djmaze commented 2 years ago

@Mer0me

The killing feature of Nextcloud Mail is unified search

Ha! I've added mockup code for it in last commit. Maybe someone will write it ๐Ÿ˜€

@cm-schl

Be aware that at the moment Nextcloud Mail is not able to search full text

When someone integrates my mockup, a lot should be possible with IMAP.

But the advanced search of SnappyMail that also allows searching based on keywords/tags and other details, i wonder if the unified search of Nextcloud is capable for that. In the past, when i developed DragonflyCMS, we figured that "unified search" was almost impossible. So we wrote an "advanced search" where you could set options for each "app", say:

jdaviescoates commented 2 years ago

Wonderful to see so much progress here, thanks all!

Presumably this will eventually be published to the Nextcloud app store?

pierre-alain-b commented 2 years ago

Excellent indeed! Happy to redirect the rainloop nextcloud plugin to a snappymail one. Let me know if I can be of any help. I can eventually help set the plugin in the nextcloud app store but there is nothing complicated there so you certainly can do it as well.

cm-schl commented 2 years ago

Would be happy to help testing the Nextcloud integration ๐Ÿ˜ƒ - could you maybe give some info how to manually install snappymail and the Nextcloud plugin in a existing Nextcloud test environment?

the-djmaze commented 2 years ago

I can eventually help set the plugin in the nextcloud app store but there is nothing complicated there

Well... i can't login https://github.com/nextcloud/appstore/issues/929 So feel free to put it in the store.

the-djmaze commented 2 years ago

could you maybe give some info how to manually install

  1. Download the snappymail-2.18.6-nextcloud.tar.gz
  2. Extract it
  3. Move/upload the extracted snappymail folder into you Nextcloud /apps/ folder
  4. Nextcloud -> Apps install the app
  5. Nextcloud -> Settings -> Admin additional -> open the snappymail admin
  6. Read https://github.com/the-djmaze/snappymail/wiki/Installation-instructions#admin-password
pierre-alain-b commented 2 years ago

I can eventually help set the plugin in the nextcloud app store but there is nothing complicated there

Well... i can't login nextcloud/appstore#929 So feel free to put it in the store.

it works here with FF 104... have you tried requesting a new password? I believe there was an update in the platform with a change of password needed.

the-djmaze commented 2 years ago

@Mer0me unified search almost working :smile_cat: ... afbeelding

the-djmaze commented 2 years ago

@cm-schl i've just tested my unified search integration and it can search the same as the advanced search of SnappyMail.

For example search keyword=$label3 or keyword:$label3 and it only shows messages with that tag/keyword/label.

So basically all works the same. The only problem is that i can't create direct links to messages yet. This requires further test and merging of my message-routing branch, as discussed in #100

the-djmaze commented 2 years ago

I've updated the release with the new options and some redesign.

Please use this version and the new plugin for further testing. It now has:

App: https://github.com/the-djmaze/snappymail/releases/download/v2.18.6/snappymail-2.18.6-nextcloud.tar.gz

Plugin: https://snappymail.eu/repository/v2/plugins/nextcloud-2.2.tgz

the-djmaze commented 2 years ago

This last commit has a working WebDAV to PROPFIND the files/directories. It should allow things like:

Now i need some time off of this and wait on you all if it works AND if someone is able to help with the integration.

There should be enough base code now to extend it all with your own wishes.

So, if everything works as expected without bugs, then this ticket should be closed and everything else should be separate feature requests.

relikd commented 2 years ago

chiming in, haven't tested it yet. Currently I am using Rainloop but consider moving to SnappyMail. Thanks for the effort so far :) ๐Ÿ‘ Can you check if the link to SnappyMail is visible in the mobile app? Because Rainloop does not show up, only external Links. But maybe this is the wrong place to ask and I should rather move the question to Nextcloud issues.

the-djmaze commented 2 years ago

@relikd

Thanks for the effort so far :) +1

Thank you!

Can you check if the link to SnappyMail is visible in the mobile app?

No idea, but wouldn't it be better to use something like FairEmail

I do use SnappyMail and FairEmail on mobile for their own purposes.

relikd commented 2 years ago

I dont want to hijack this thread, so I keep it short. My use-case is a nextcould instance for a non-profit to allow collaboration. The email accounts are pre-configured and assigned to specific users. Each user can have 0-n email accounts. Giving away login/passwords would require to change the pw each time a user quits and the remaining users would need to update their stored pw. But again, I dont want to hijack the thread. Just a feature wish: as an admin I would like to pre-configure accounts for others. Currently I do that with the Impersonate app.

rainerzufall commented 2 years ago

I am very happy to see that the nextcloud integration is happening. Thank you so much for your effort and time spent on this, the-djmaze!! ๐Ÿ™‡ Just wanted to let you know, that I will be able to help test as soon it hits the nextcloud AppStore, as I am not tech savvy enough to run my own nextcloud instance and test at the current stage of development.