gnanet / mailzu

MailZu-ng compatible PHP 7.2+, PHP-PDO | Based on zedzedtop/mailzu and SF.net/projects/mailzu/ | MailZu is a simple and intuitive web interface to manage Amavisd-new quarantine. Users can view their own quarantine, release/delete messages or request the release of messages. This fork of MailZu is written in PHP and requires Amavisd-new version greater than 2.7.0
GNU General Public License v2.0
14 stars 7 forks source link

PHP 8.X compatibility #17

Open piperino721 opened 9 months ago

piperino721 commented 9 months ago

Hello

Are there any plans to make your mailzu fork compatible with PHP 8+. Got it partially working copying some files over from a Freebsd Repo. https://www.freshports.org/security/mailzu/ Unfortunately, i have no coding skills but could help testing.

cheer

apio-sys commented 9 months ago

How far have you come? What are the remaining errors? That could give some indication of how much work there is to do.

piperino721 commented 9 months ago

How far have you come? What are the remaining errors? That could give some indication of how much work there is to do.

I use it on openSuse Leap 15.5 with PHP 8.1.24

-Since i just using LDAP i can say LDAP Login is working. -Site Quarantine overview as admin is working -User Quarantine overview is working. -Open a quarantined mail is NOT working. all mail field are empty. image

-Release quarantined mail is NOT working. it tells me can't connect. even though port is listening. amavisd-release is working just fine. image

tnx

apio-sys commented 9 months ago

It would be good what errors you are getting from your webserver logs. That should indicate where there is work to do.

piperino721 commented 9 months ago

It would be good what errors you are getting from your webserver logs. That should indicate where there is work to do.

No errors in logs while trying to release a mail from quarantine

### Whatever errors:)

[Sun Feb 25 11:10:06.468215 2024] [php:warn] [pid 25428] [client 1.1.1.1:52206] PHP Warning: Undefined variable $content_type in /srv/www/htdocs/mz-test/messagesPendingAdmin.php on line 57, referer: https://mydomain.abc/mz-test/messagesAdmin.php?t_criterion=contains&t_string=&m_criterion=contains&m_string=&f_criterion=contains&f_string=&s_criterion=contains&s_string=&ctype=A&search_action=Search [Sun Feb 25 11:10:08.345327 2024] [php:warn] [pid 25428] [client 1.1.1.1:52206] PHP Warning: Undefined variable $content_type in /srv/www/htdocs/mz-test/messagesPendingAdmin.php on line 57, referer: https://mydomain.abc/mz-test/messagesPendingAdmin.php?ctype=A [Sun Feb 25 11:12:19.290923 2024] [php:warn] [pid 25427] [client 1.1.1.1:52222] PHP Warning: Undefined variable $emailaddresses in /srv/www/htdocs/mz-test/lib/DBEngine.class.php on line 500, referer: https://mydomain.abc/mz-test/messagesAdmin.php?t_criterion=contains&t_string=&m_criterion=contains&m_string=&f_criterion=contains&f_string=&s_criterion=contains&s_string=&ctype=A&search_action=Search [Sun Feb 25 11:12:19.430355 2024] [php:warn] [pid 25427] [client 1.1.1.1:52222] PHP Warning: Uninitialized string offset 0 in /usr/share/php/PEAR/Mail/mimeDecode.php on line 491, referer: https://mydomain.abc/mz-test/messagesAdmin.php?t_criterion=contains&t_string=&m_criterion=contains&m_string=&f_criterion=contains&f_string=&s_criterion=contains&s_string=&ctype=A&search_action=Search [Sun Feb 25 11:12:19.430532 2024] [php:warn] [pid 25427] [client 1.1.1.1:52222] PHP Warning: Undefined array key "from" in /srv/www/htdocs/mz-test/templates/viewmail.template.php on line 55, referer: https://mydomain.abc/mz-test/messagesAdmin.php?t_criterion=contains&t_string=&m_criterion=contains&m_string=&f_criterion=contains&f_string=&s_criterion=contains&s_string=&ctype=A&search_action=Search [Sun Feb 25 11:12:19.430548 2024] [php:warn] [pid 25427] [client 1.1.1.1:52222] PHP Warning: Undefined array key "to" in /srv/www/htdocs/mz-test/templates/viewmail.template.php on line 55, referer: https://mydomain.abc/mz-test/messagesAdmin.php?t_criterion=contains&t_string=&m_criterion=contains&m_string=&f_criterion=contains&f_string=&s_criterion=contains&s_string=&ctype=A&search_action=Search [Sun Feb 25 11:12:19.430557 2024] [php:warn] [pid 25427] [client 1.1.1.1:52222] PHP Warning: Undefined array key "date" in /srv/www/htdocs/mz-test/templates/viewmail.template.php on line 55, referer: https://mydomain.abc/mz-test/messagesAdmin.php?t_criterion=contains&t_string=&m_criterion=contains&m_string=&f_criterion=contains&f_string=&s_criterion=contains&s_string=&ctype=A&search_action=Search [Sun Feb 25 11:12:19.430565 2024] [php:warn] [pid 25427] [client 1.1.1.1:52222] PHP Warning: Undefined array key "subject" in /srv/www/htdocs/mz-test/templates/viewmail.template.php on line 55, referer: https://mydomain.abc/mz-test/messagesAdmin.php?t_criterion=contains&t_string=&m_criterion=contains&m_string=&f_criterion=contains&f_string=&s_criterion=contains&s_string=&ctype=A&search_action=Search [Sun Feb 25 11:12:19.430575 2024] [php:warn] [pid 25427] [client 1.1.1.1:52222] PHP Warning: Undefined variable $header_value in /srv/www/htdocs/mz-test/templates/viewmail.template.php on line 87, referer: https://mydomain.abc/mz-test/messagesAdmin.php?t_criterion=contains&t_string=&m_criterion=contains&m_string=&f_criterion=contains&f_string=&s_criterion=contains&s_string=&ctype=A&search_action=Search [Sun Feb 25 11:12:19.430582 2024] [php:warn] [pid 25427] [client 1.1.1.1:52222] PHP Warning: Undefined variable $header_value in /srv/www/htdocs/mz-test/templates/viewmail.template.php on line 87, referer: https://mydomain.abc/mz-test/messagesAdmin.php?t_criterion=contains&t_string=&m_criterion=contains&m_string=&f_criterion=contains&f_string=&s_criterion=contains&s_string=&ctype=A&search_action=Search [Sun Feb 25 11:12:19.430602 2024] [php:warn] [pid 25427] [client 1.1.1.1:52222] PHP Warning: Undefined variable $header_value in /srv/www/htdocs/mz-test/templates/viewmail.template.php on line 87, referer: https://mydomain.abc/mz-test/messagesAdmin.php?t_criterion=contains&t_string=&m_criterion=contains&m_string=&f_criterion=contains&f_string=&s_criterion=contains&s_string=&ctype=A&search_action=Search [Sun Feb 25 11:12:19.430609 2024] [php:warn] [pid 25427] [client 1.1.1.1:52222] PHP Warning: Undefined variable $header_value in /srv/www/htdocs/mz-test/templates/viewmail.template.php on line 87, referer: https://mydomain.abc/mz-test/messagesAdmin.php?t_criterion=contains&t_string=&m_criterion=contains&m_string=&f_criterion=contains&f_string=&s_criterion=contains&s_string=&ctype=A&search_action=Search

### open mail

[Sun Feb 25 11:16:22.379448 2024] [php:warn] [pid 3497] [client 1.1.1.1:52240] PHP Warning: Undefined variable $emailaddresses in /srv/www/htdocs/mz-test/lib/DBEngine.class.php on line 500, referer: https://mydomain.abc/mz-test/messagesIndex.php?ctype=A [Sun Feb 25 11:16:22.471888 2024] [php:warn] [pid 3497] [client 1.1.1.1:52240] PHP Warning: Uninitialized string offset 0 in /usr/share/php/PEAR/Mail/mimeDecode.php on line 491, referer: https://mydomain.abc/mz-test/messagesIndex.php?ctype=A [Sun Feb 25 11:16:22.472068 2024] [php:warn] [pid 3497] [client 1.1.1.1:52240] PHP Warning: Undefined array key "from" in /srv/www/htdocs/mz-test/templates/viewmail.template.php on line 55, referer: https://mydomain.abc/mz-test/messagesIndex.php?ctype=A [Sun Feb 25 11:16:22.472083 2024] [php:warn] [pid 3497] [client 1.1.1.1:52240] PHP Warning: Undefined array key "to" in /srv/www/htdocs/mz-test/templates/viewmail.template.php on line 55, referer: https://mydomain.abc/mz-test/messagesIndex.php?ctype=A [Sun Feb 25 11:16:22.472092 2024] [php:warn] [pid 3497] [client 1.1.1.1:52240] PHP Warning: Undefined array key "date" in /srv/www/htdocs/mz-test/templates/viewmail.template.php on line 55, referer: https://mydomain.abc/mz-test/messagesIndex.php?ctype=A [Sun Feb 25 11:16:22.472099 2024] [php:warn] [pid 3497] [client 1.1.1.1:52240] PHP Warning: Undefined array key "subject" in /srv/www/htdocs/mz-test/templates/viewmail.template.php on line 55, referer: https://mydomain.abc/mz-test/messagesIndex.php?ctype=A [Sun Feb 25 11:16:22.472108 2024] [php:warn] [pid 3497] [client 1.1.1.1:52240] PHP Warning: Undefined variable $header_value in /srv/www/htdocs/mz-test/templates/viewmail.template.php on line 87, referer: https://mydomain.abc/mz-test/messagesIndex.php?ctype=A [Sun Feb 25 11:16:22.472115 2024] [php:warn] [pid 3497] [client 1.1.1.1:52240] PHP Warning: Undefined variable $header_value in /srv/www/htdocs/mz-test/templates/viewmail.template.php on line 87, referer: https://mydomain.abc/mz-test/messagesIndex.php?ctype=A [Sun Feb 25 11:16:22.472121 2024] [php:warn] [pid 3497] [client 1.1.1.1:52240] PHP Warning: Undefined variable $header_value in /srv/www/htdocs/mz-test/templates/viewmail.template.php on line 87, referer: https://mydomain.abc/mz-test/messagesIndex.php?ctype=A [Sun Feb 25 11:16:22.472128 2024] [php:warn] [pid 3497] [client 1.1.1.1:52240] PHP Warning: Undefined variable $header_value in /srv/www/htdocs/mz-test/templates/viewmail.template.php on line 87, referer: https://mydomain.abc/mz-test/messagesIndex.php?ctype=A

hope this helps a bit

gnanet commented 9 months ago

It seems mycomment got vanished. First in composer.json there is a php 7.2 as far i know. To fix most PHP upmigration issues, i would use RectorPHP

apio-sys commented 9 months ago

@piperino721 even though the warnings don't look nice, I don't think they are actual showstoppers or you would have seen Fatal Errors in your log. After a previous U/G from Debian 10 to 11 and thus PHP 7.2 to 7.4 I had a similar error (at least I think it is similar to yours) where mailzu hangs on "retrieving messages". I found out that the mbstring extension was missing in PHP. Hence a simple:

apt-get install php-mbstring

solved that. Maybe that is your case as well? Maybe go through all PHP config and chech against a working installation (my highest install is on 7.4).

piperino721 commented 9 months ago

@piperino721 even though the warnings don't look nice, I don't think they are actual showstoppers or you would have seen Fatal Errors in your log. After a previous U/G from Debian 10 to 11 and thus PHP 7.2 to 7.4 I had a similar error (at least I think it is similar to yours) where mailzu hangs on "retrieving messages". I found out that the mbstring extension was missing in PHP. Hence a simple:

apt-get install php-mbstring

solved that. Maybe that is your case as well? Maybe go through all PHP config and chech against a working installation (my highest install is on 7.4).

php81-mbstring is installed here.

apio-sys commented 9 months ago

OK that was just a hunch. There must be something else blocking. The warnings in your log don't explain this. Try and put your PHP to debug level, for example via your php.ini to so if you can capture some more info.

piperino721 commented 9 months ago

this is what i get with "display_errors = On" in php.ini

[Tue Feb 27 15:44:11.759494 2024] [php:warn] [pid 17803] [client 1.1.1.1:54700] PHP Warning: Undefined variable $emailaddresses in /srv/www/htdocs/mz-test/lib/DBEngine.class.php on line 500, referer: https://mydomain.abc/mz-test/messagesIndex.php?ctype=A [Tue Feb 27 15:44:12.548797 2024] [php:warn] [pid 17803] [client 1.1.1.1:54700] PHP Warning: Uninitialized string offset 0 in /usr/share/php/PEAR/Mail/mimeDecode.php on line 491, referer: https://mydomain.abc/mz-test/messagesIndex.php?ctype=A [Tue Feb 27 15:44:12.548981 2024] [php:warn] [pid 17803] [client 1.1.1.1:54700] PHP Warning: Undefined array key "from" in /srv/www/htdocs/mz-test/templates/viewmail.template.php on line 55, referer: https://mydomain.abc/mz-test/messagesIndex.php?ctype=A [Tue Feb 27 15:44:12.549001 2024] [php:warn] [pid 17803] [client 1.1.1.1:54700] PHP Warning: Undefined array key "to" in /srv/www/htdocs/mz-test/templates/viewmail.template.php on line 55, referer: https://mydomain.abc/mz-test/messagesIndex.php?ctype=A [Tue Feb 27 15:44:12.549012 2024] [php:warn] [pid 17803] [client 1.1.1.1:54700] PHP Warning: Undefined array key "date" in /srv/www/htdocs/mz-test/templates/viewmail.template.php on line 55, referer: https://mydomain.abc/mz-test/messagesIndex.php?ctype=A [Tue Feb 27 15:44:12.549023 2024] [php:warn] [pid 17803] [client 1.1.1.1:54700] PHP Warning: Undefined array key "subject" in /srv/www/htdocs/mz-test/templates/viewmail.template.php on line 55, referer: https://mydomain.abc/mz-test/messagesIndex.php?ctype=A [Tue Feb 27 15:44:12.549034 2024] [php:warn] [pid 17803] [client 1.1.1.1:54700] PHP Warning: Undefined variable $header_value in /srv/www/htdocs/mz-test/templates/viewmail.template.php on line 87, referer: https://mydomain.abc/mz-test/messagesIndex.php?ctype=A [Tue Feb 27 15:44:12.549043 2024] [php:warn] [pid 17803] [client 1.1.1.1:54700] PHP Warning: Undefined variable $header_value in /srv/www/htdocs/mz-test/templates/viewmail.template.php on line 87, referer: https://mydomain.abc/mz-test/messagesIndex.php?ctype=A [Tue Feb 27 15:44:12.549052 2024] [php:warn] [pid 17803] [client 1.1.1.1:54700] PHP Warning: Undefined variable $header_value in /srv/www/htdocs/mz-test/templates/viewmail.template.php on line 87, referer: https://mydomain.abc/mz-test/messagesIndex.php?ctype=A [Tue Feb 27 15:44:12.549062 2024] [php:warn] [pid 17803] [client 1.1.1.1:54700] PHP Warning: Undefined variable $header_value in /srv/www/htdocs/mz-test/templates/viewmail.template.php on line 87, referer: https://mydomain.abc/mz-test/messagesIndex.php?ctype=A

**Just saw when i try to release a message it is trying to connect to the FQDN of the server on port 9998 which is of course not allowed. even though in the config is: // Set Amavisd-new host, if AM.PDP only allowed over localhost $conf['amavisd']['host'] = 'localhost';

also tried 127.0.0.1 but it makes no difference.**

apio-sys commented 9 months ago

Your log shows only warnings so the issue doesn't come from there. It might well be a system/configuration issue. Indeed amavisd runs on 127.0.0.1:9998 and that's where it should be adressed. You should have this in your config/config.php:

// Amavisd-new AM.PDP port
// Since the port number can not be stored in the database
// all instances of amavisd-new must use the same AM.PDP port 
$conf['amavisd']['spam_release_port'] = '9998';

// Set Amavisd-new host, if AM.PDP only allowed over localhost
$conf['amavisd']['host'] = '127.0.0.1';

which can't point to the FQDN...

piperino721 commented 9 months ago

The logs are written while trying to open a quarantined mail. thats one issue. the other is releasing mails. My config for the AM.PDP looks exactly like yours's. Whatever i put in "$conf['amavisd']['host']" i always get "Error connecting to hostname.mydomain:9998, Connection refused" But maybe this is just a generic error from the GUI and there is another Underlying firing the amavisd-release command

no idea why PHP/mailzu is doing this

Besides that the system runs fine for years.

apio-sys commented 9 months ago

Difficult to say but IMHO it still doesn't look like a pure PHP issue. When I release a quaraintained mail, I see following in the webserver logs:

[27/Feb/2024:16:19:56 +0100] "POST /mail-quarantaine/messagesProcessing.php HTTP/2.0" 200 2309 "https://example.com/mail-quarantaine/read_mail.php?mail_id=XPS6_vHb0Yed&recip_email=ping%40example.com&ctype=A&searchOnly=0" "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:123.0) Gecko/20100101 Firefox/123.0"
[27/Feb/2024:16:19:56 +0100] "GET /mail-quarantaine/messagesAdmin.php?ctype=A&searchOnly=0 HTTP/2.0" 200 4930 "https://example.com/mail-quarantaine/messagesProcessing.php" "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:123.0) Gecko/20100101 Firefox/123.0"

Maybe you can better see what happens here when the error in the GUI occurs?

piperino721 commented 9 months ago

below is all i get. i think it's something in the code or with some PHP libraries needed for mailzu is wrong or missing. also on the same machine nextcloud and roundcube is running fine. the error from the is already posted.

BTW. you run it on php8 or php7?

==> /var/log/apache2/access_log <== 1.1.1.1 - - [27/Feb/2024:17:21:08 +0100] "GET /mz-test/messagesAdmin.php?t_criterion=contains&t_string=&m_criterion=contains&m_string=&f_criterion=contains&f_string=&s_criterion=contains&s_string=&ctype=A&search_action=Search HTTP/1.1" 200 64077

==> /var/log/apache2/ssl_request_log <== [27/Feb/2024:17:21:08 +0100] 1.1.1.1 TLSv1.3 TLS_AES_256_GCM_SHA384 "GET /mz-test/messagesAdmin.php?t_criterion=contains&t_string=&m_criterion=contains&m_string=&f_criterion=contains&f_string=&s_criterion=contains&s_string=&ctype=A&search_action=Search HTTP/1.1" 64077 "https://mydomain.abc/mz-test/messagesAdmin.php?t_criterion=contains&t_string=&m_criterion=contains&m_string=&f_criterion=contains&f_string=&s_criterion=contains&s_string=&ctype=A&search_action=Search" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/122.0.0.0 Safari/537.36 Edg/122.0.0.0"

apio-sys commented 9 months ago

I'm still running this on 2 machines both on PHP 7.4. I can't U/G PHP as yet since I have other software that I know is not compatible. Maybe MailZu isn't neither but we haven't really proved that unfortunately... To be able to further help, I would need to change the PHP version of one of my machines but can't do immediately since these are prod... I'm not sure if I can help further. Did you notice the change directly upon upgrading that machine or upon moving the webapp to a different server? The call of FQDN rather than localhost still sounds fishy and I'm almost convinced it's not PHP and some sysconf somewhere...

piperino721 commented 9 months ago

No worries. i just thought i can't loose anything asking here:). i think mailzu stopped working when i upgraded to php8+ .