Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

First-class support for Nextcloud #96

Closed
pemocarlo opened this issue Jun 21, 2021 · 100 comments
Closed

First-class support for Nextcloud #96

pemocarlo opened this issue Jun 21, 2021 · 100 comments
Labels
enhancement New feature or request help wanted Extra attention is needed Nextcloud

Comments

@pemocarlo
Copy link

pemocarlo commented Jun 21, 2021

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: RainLoop#2023

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

@the-djmaze
Copy link
Owner

the-djmaze commented Jul 14, 2021

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
Copy link

Mer0me commented Jul 14, 2021

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
Copy link
Author

@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 pushed a commit that referenced this issue Jul 16, 2021
@the-djmaze
Copy link
Owner

the-djmaze commented Jul 16, 2021

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.
6e26c76

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
Copy link
Owner

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
Copy link
Author

pemocarlo commented Jul 16, 2021

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
Copy link
Owner

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
Copy link

Mer0me commented Jul 17, 2021

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

  • Create an official app to install Snappymail in Nextcloud as the rainloop app does
  • Allow SnappyMail to save mail and attachments to Nextcloud, and to pick attachments from Nextcloud
  • Add SnappyMail search into the Nextcloud search bar, and show last received mails in Nextcloud dashboard

That would be awesome !

@Mer0me
Copy link

Mer0me commented Jul 17, 2021

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

@scubamuc
Copy link

@the-djmaze

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

@the-djmaze
Copy link
Owner

the-djmaze commented Jul 20, 2021

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
Copy link
Owner

the-djmaze commented Aug 20, 2021

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
Copy link

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

@Mer0me
Copy link

Mer0me commented Sep 28, 2021

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
Copy link
Owner

the-djmaze commented Oct 22, 2021

@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
Copy link

cm-schl commented Feb 1, 2022

Hi,

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

@scubamuc
Copy link

scubamuc commented Feb 1, 2022

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
Copy link
Owner

the-djmaze commented Apr 5, 2022

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

@HeyVern
Copy link

HeyVern commented May 6, 2022

@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
Copy link

husim0 commented Jul 20, 2022

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
Copy link

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
Copy link

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

@schengawegga
Copy link

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.

@Magneticdud
Copy link

Great work! Replaced rainloop without effort, and much faster than native nextcloud mail

For saving, it doesn't save the .eml file; for attachments it creates the Attachments folder (or different, in changed in the plugin setting, i guess), but then doesn't save the file

@Mer0me
Copy link

Mer0me commented Oct 18, 2022

Same issue : Attachments folder created, but empty

@szaimen
Copy link

szaimen commented Oct 18, 2022

Regardung this setting: Improvement idea: let each user choose an attachment folder in the user settings as I know of cases where each user needs to have a different folder

@relikd
Copy link

relikd commented Oct 18, 2022

Upon uninstalling and re-installing snappymail, I get this error from Nextcloud UI: "App with id snappymail has invalid signature"

@daffydock
Copy link

Ha, @relikd beat me to the punch. Earlier, I was able to install Snappymail via console, version 2.19.0r RC1, and was running just fine, sans plugins, as they did not seem to work. Which was fine, main functionality was there. Noticed an update available and from console, got the same error as them, with version 2.19.

"Error: App with id snappymail has invalid signature"

@the-djmaze
Copy link
Owner

For saving, it doesn't save the .eml file; for attachments it creates the Attachments

I will look into this issue

Improvement idea: let each user choose an attachment folder in the user settings as I know of cases where each user needs to have a different folder

Actually there is a webdav.js that works. The idea is to create a popup view where you can select/create folder to put them in.

Upon uninstalling and re-installing snappymail, I get this error from Nextcloud UI: "App with id snappymail has invalid signature"

Correct! I uploaded a new version with same name to see what will happen.
As it seems it will override the existing version!
This is something i need to watch out for in future that Nextcloud website doesn't warn or error for existing version and that it can take some time before the new signature will kick in.
I will fix this as well.

@daffydock
Copy link

Upon uninstalling and re-installing snappymail, I get this error from Nextcloud UI: "App with id snappymail has invalid signature"

Correct! I uploaded a new version with same name to see what will happen. As it seems it will override the existing version! This is something i need to watch out for in future that Nextcloud website doesn't warn or error for existing version and that it can take some time before the new signature will kick in. I will fix this as well.

Alright. Tried it again, and it works. Downloaded and enabled successfully.

@the-djmaze
Copy link
Owner

@Mer0me i've fixed the plugin for you.
v2.4 should work and it has some draft code for a directory/files selector window.

@the-djmaze
Copy link
Owner

Great work! Replaced rainloop without effort, and much faster than native nextcloud mail

Great to hear @Magneticdud !

@webagroprom
Copy link

webagroprom commented Oct 18, 2022

@SelfRef the Nextcloud log should have information why you get a 500 error.

@webagroprom i've improved the Nextcloud admin settings to show the initial password and an option to enable/disable debug mode.

  1. Im update snappy mail ( remove or install )
sudo -u nginx php occ app:remove snappymail
sudo -u nginx php occ app:install snappymail --allow-unstable 
  1. Enable Debug mod in admin panel
  2. Cope login and pass from admin panel
  3. Open link - admin panel snappy mail

admin panel

1666115623780

Constant Loading:

1666114950707

Browser: safari, firefox
Nextcloud: 24.0.6 stable
Log nextcloud is empty
Rainloop is enable
Snappy mail is enable

Im try change password on the example: 12345W and drop cache browser = result the same

After changing the password from the admin panel, I checked the default configuration file - the password data did not change:

/nextcloud/data/appdata_snappymail/_data_/_default_/configs/application.ini

; Login and password for web admin panel
admin_login = "admin"
admin_password = "$2y$10$5gfr3EyNw4QdgZuPVwmMj.4zRXkkvUVbBHTv8YprEf/ajvO2NUGhn"
admin_totp = ""

Solution

Remove app snappy mail or folder:

sudo -u nginx php occ app:remove snappymail
rm -Rf /nextcloud/data/appdata_snappymail/

Result
Log in correctly

@SelfRef
Copy link

SelfRef commented Oct 18, 2022

Indeed, removing SnappyMail completely and installing again solved the issue. Thanks @webagroprom.

@webagroprom
Copy link

webagroprom commented Oct 18, 2022

@SelfRef the Nextcloud log should have information why you get a 500 error.
@webagroprom i've improved the Nextcloud admin settings to show the initial password and an option to enable/disable debug mode.

  1. Im update snappy mail ( remove or install )
sudo -u nginx php occ app:remove snappymail
sudo -u nginx php occ app:install snappymail --allow-unstable 
  1. Enable Debug mod in admin panel
  2. Cope login and pass from admin panel
  3. Open link - admin panel snappy mail

admin panel

1666115623780

Constant Loading:

1666114950707

Browser: safari, firefox Nextcloud: 24.0.6 stable Log nextcloud is empty Rainloop is enable Snappy mail is enable

Im try change password on the example: 12345W and drop cache browser = result the same

After changing the password from the admin panel, I checked the default configuration file - the password data did not change:

/nextcloud/data/appdata_snappymail/_data_/_default_/configs/application.ini

; Login and password for web admin panel
admin_login = "admin"
admin_password = "$2y$10$5gfr3EyNw4QdgZuPVwmMj.4zRXkkvUVbBHTv8YprEf/ajvO2NUGhn"
admin_totp = ""

Solution

Remove app snappy mail or folder:

sudo -u nginx php occ app:remove snappymail
rm -Rf /nextcloud/data/appdata_snappymail/

Result Log in correctly

When changing the password to the snappy mail admin panel through the admin panel, the authorization data disappears:

1666123466038

When you try to log into the admin panel with a new password:
Constant loading

1666114950707

If I change the password not through the admin panel, but through the file: admin_password.txt

Error:
Authorisation failed or Constant loading

@Mer0me
Copy link

Mer0me commented Oct 19, 2022

@Mer0me i've fixed the plugin for you. v2.4 should work and it has some draft code for a directory/files selector window.

Ok, saving .eml works now. Nice work !

@the-djmaze
Copy link
Owner

the-djmaze commented Oct 19, 2022

@webagroprom and @SelfRef i've figured it out!

When debug mode is on, SnappyMail uses the Content-Security-Policy-Report-Only header.
However, Nextcloud already set the Content-Security-Policy so there are two conflicting CSP headers.
Fixed this by removing the CSP header of Nextcloud.

If I change the password not through the admin panel, but through the file: admin_password.txt

Correct, that file is only temporary and should not be edited.

@the-djmaze
Copy link
Owner

Release 2.19.0.1 and 2.19.01 not possible and 2.19.0-1 gets marked as unstable.
So i've made it 2.19.1

You must manually update extension/plugin to 2.5!

It includes:

  • PharData workaround (just try it)
  • Plugin has basic Nextcloud folder selector (no sub-tree yet) to save attachments/email
  • Fix for Content-Security-Policy
  • Some other cleanups and improvements

I shall close this ticket and any further issues/features can be done in new issues.
Because the current release already has much more integration then the RainLoop version.
I've also opened the Discussions section so you all can talk about this there as well
https://github.com/the-djmaze/snappymail/discussions

@jdaviescoates
Copy link

Just installed this. Once I'd set-up my domains in the admin settings it works great, many thanks!

@relikd
Copy link

relikd commented Oct 19, 2022

  • PharData workaround (just try it)

works like a charm (y)

@beankylla
Copy link

thanks a lot @the-djmaze works like a charrmmm :)

@schengawegga
Copy link

Yesterday i installed snappymail on my nextcloud 24.0.5 via the app menu. It worked without any problems. Thanks you @the-djmaze for your amazing support.

@jiriks74
Copy link

Well, this looks promising!

Rant about old Rainloop or weird plugin setup in Roundcube

Since Rainloop is currently old (and probably unsecure) pain, I've pluginned the hell out of Roundcube to get multiple emails. I made it work well, but as it's a plugin it does create some weird behaviour like: you can setup special folders like Inbox for every account separately but you cannot setup Archive folder separately as that is a plugin. So you have to have the archive folder under the same name for all accounts (which is pain because of Gmail - in Czech it's called "Všechny zprávy" not Archive and it's not an imap folder, urghh...). But it kinda works

I'll sure take a look into this plugin as it's what I wanted in the begining. Simple, multiemail webapp that's easy to run with nextcloud (Roundcube doesn't run with Nextcloud at all...). Looks way to promising to be true actually!

I've seen that the Nextcloud integration is WIP, but I'll take that and thank you for it.

This has just made my day and I haven't even tried it yet LOL

@hampoelz hampoelz mentioned this issue Nov 5, 2022
13 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request help wanted Extra attention is needed Nextcloud
Projects
None yet
Development

No branches or pull requests