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

cPanel 3rdparty integration #697

Closed
the-djmaze opened this issue Nov 24, 2022 · 2 comments
Closed

cPanel 3rdparty integration #697

the-djmaze opened this issue Nov 24, 2022 · 2 comments

Comments

@the-djmaze
Copy link
Owner

the-djmaze commented Nov 24, 2022

Issue #645 is almost the same, so i did a test on a server with cPanel.
There are several issues at play, including cPanel bugs before it works.

Setup

  1. Download snappymail-*-cpanel.tar.gz from https://github.com/the-djmaze/snappymail/releases/latest
  2. Extract file
  3. Upload the content to your server root (/)
  4. Open a webmail account from WHM and choose SnappyMail

Basically something should work, but...

The CSS bug

cPanel modifies CSS files and replaces url(/path) into url(/cPanel_magic_revision_0000000000/path)

But SnappyMail also uses:
url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg'")
and cPanel breaks this into
url(data:image/svg+xml,<svg xmlns='http:/www.w3.org/2000/svg'")

There are two issues here:

  1. the double quote at the beginning is removed (not at the end)
  2. http:// is missing a slash

Automate logins issue

According to https://api.docs.cpanel.net/guides/quickstart-development-guide/tutorial-integrate-custom-webmail-applications/#webmail-application-modifications
we must use REMOTE_USER and REMOTE_PASSWORD.
Both are available in $_SERVER and $_ENV so the "Login Remote" extension should work.

In the yaml i use url: "/3rdparty/snappymail/?RemoteAutoLogin" and the extension is working.
But IMAP responds with:

IMAP[INFO]: < * OK [CAPABILITY IMAP4rev1 SASL-IR LOGIN-REFERRALS ID ENABLE IDLE NAMESPACE LITERAL+ STARTTLS AUTH=PLAIN AUTH=LOGIN] Dovecot ready.\r\n
IMAP[INFO]: > TAG1 AUTHENTICATE PLAIN Base64=\r\n
IMAP[INFO]: < TAG1 NO [AUTHENTICATIONFAILED] Authentication failed.\r\n

As it seems, REMOTE_USER is not the login name and needs part of REMOTE_PASSWORD.
Solved here 2947304

File permissions

PHP runs as the user, so data must be stored in own user directory.
Currently /usr/local/cpanel/base/3rdparty/snappymail/data/_data_/_default_/ will fail for multiple users.
Therefore SnappyMail v2.22.2+ has a new initialization script that is run when /home/<username>/var/snappymail/_data_/_default_/plugins/login-remote does not exist.
https://github.com/the-djmaze/snappymail/blob/master/snappymail/v/0.0.0/cpanel.php

Benchmark

This is a very simple benchmark test i made between Roundcube and SnappyMail inside cPanel for an empty and filled Inbox.
RoundCube:
afbeelding
afbeelding
SnappyMail:
afbeelding
afbeelding

Feel free to do better tests if you really want to know which is mostly faster.

the-djmaze pushed a commit that referenced this issue Nov 24, 2022
@the-djmaze
Copy link
Owner Author

the-djmaze commented Nov 24, 2022

The issues are fixed now and it works in cPanel, but will keep open for more todo

the-djmaze pushed a commit that referenced this issue Nov 24, 2022
the-djmaze pushed a commit that referenced this issue Nov 24, 2022
the-djmaze pushed a commit that referenced this issue Nov 25, 2022
@the-djmaze
Copy link
Owner Author

In v2.22.3 i've added a feature to configure path for logs and cache.
This way the integration in cPanel is cleaner and data will be stored at:

  • /home/<username>/var/snappymail contains the data
  • /home/<username>/logs/snappymail contains logs (when active)
  • /home/<username>/tmp/snappymail contains the cache

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant