From 81a1d456173aae86bf234c512f3a21fa6ac98ade Mon Sep 17 00:00:00 2001 From: David Goodwin Date: Mon, 1 Apr 2024 19:32:27 +0100 Subject: [PATCH] drop use of the deprecated PHP imap extension (php-imap) - see #472 and #812 --- INSTALL.TXT | 6 ---- debian/control | 2 +- model/MailboxHandler.php | 69 +++------------------------------------- public/setup.php | 9 ------ 4 files changed, 6 insertions(+), 80 deletions(-) diff --git a/INSTALL.TXT b/INSTALL.TXT index d7f52237..559aa252 100644 --- a/INSTALL.TXT +++ b/INSTALL.TXT @@ -174,12 +174,6 @@ And if the webserver (PHP) needs to make network connections out to a database s semanage boolean -m --on httpd_can_network_connect_db ```` -If additionally, needing the webserver (PHP) to talk to an imap server, then you'll probably also need: - -```bash - semanage boolean -m --on httpd_can_network_connect -```` - 5. Check settings, and create Admin user ---------------------------------------- diff --git a/debian/control b/debian/control index ae609b7d..5363b739 100644 --- a/debian/control +++ b/debian/control @@ -11,7 +11,7 @@ Homepage: http://postfixadmin.sourceforge.net Package: postfixadmin Architecture: all -Depends: debconf (>= 0.5), dbconfig-common, wwwconfig-common, apache2 | lighttpd | httpd, libapache2-mod-php | php-cgi | php-fpm | php, php-imap, php-mysql | php-mysqlnd | php-pgsql | php-sqlite3, php-mbstring, default-mysql-client | postgresql-client | mariadb-client, ${misc:Depends} +Depends: debconf (>= 0.5), dbconfig-common, wwwconfig-common, apache2 | lighttpd | httpd, libapache2-mod-php | php-cgi | php-fpm | php, php-mysql | php-mysqlnd | php-pgsql | php-sqlite3, php-mbstring, default-mysql-client | postgresql-client | mariadb-client, ${misc:Depends} Recommends: postfix-mysql | postfix-pgsql, virtual-mysql-server | postgresql | sqlite3 (>= 3.12.0) | mariadb-server, zendframework, dovecot-core | courier-authlib-mysql | courier-authlib-postgresql, php-cli Description: Virtual mail hosting interface for Postfix Postfixadmin is a web interface to manage virtual users and domains diff --git a/model/MailboxHandler.php b/model/MailboxHandler.php index 105fbef0..242d5cbe 100644 --- a/model/MailboxHandler.php +++ b/model/MailboxHandler.php @@ -749,76 +749,17 @@ protected function mailbox_postdeletion() */ protected function create_mailbox_subfolders() { + // no longer implemented; code relied on deprecated PHP imap extension. + $create_mailbox_subdirs = Config::read('create_mailbox_subdirs'); if (empty($create_mailbox_subdirs)) { return true; } - if (!function_exists('imap_open')) { - trigger_error('imap_open function not present; cannot create_mailbox_subdirs'); - return false; - } - - if (!is_array($create_mailbox_subdirs)) { - trigger_error('create_mailbox_subdirs must be an array', E_USER_ERROR); - return false; - } - - $s_host = Config::read_string('create_mailbox_subdirs_host'); - if (empty($s_host)) { - trigger_error('An IMAP/POP server host ($CONF["create_mailbox_subdirs_host"]) must be configured, if sub-folders are to be created', E_USER_ERROR); - return false; - } - - $s_options=''; - - $create_mailbox_subdirs_hostoptions = Config::read('create_mailbox_subdirs_hostoptions'); - if (!empty($create_mailbox_subdirs_hostoptions)) { - if (!is_array($create_mailbox_subdirs_hostoptions)) { - trigger_error('The $CONF["create_mailbox_subdirs_hostoptions"] parameter must be an array', E_USER_ERROR); - return false; - } - foreach ($create_mailbox_subdirs_hostoptions as $o) { - $s_options.='/'.$o; - } - } - - $s_port=''; - if (Config::has('create_mailbox_subdirs_hostport')) { - $create_mailbox_subdirs_hostport = Config::read('create_mailbox_subdirs_hostport'); - if (!empty($create_mailbox_subdirs_hostport)) { - $s_port = $create_mailbox_subdirs_hostport; - if (intval($s_port)!=$s_port) { - trigger_error('The $CONF["create_mailbox_subdirs_hostport"] parameter must be an integer', E_USER_ERROR); - return false; - } - $s_port=':'.$s_port; - } - } - - $s='{'.$s_host.$s_port.$s_options.'}'; - - sleep(1); # give the mail triggering the mailbox creation a chance to do its job - - $i=@imap_open($s, $this->id, $this->values['password']); - if (false==$i) { - error_log('Could not log into IMAP/POP server: ' . $this->id . ': ' . imap_last_error()); - return false; - } - - $s_prefix = Config::read_string('create_mailbox_subdirs_prefix'); - foreach ($create_mailbox_subdirs as $f) { - $f='{'.$s_host.'}'.$s_prefix.$f; - $res=imap_createmailbox($i, $f); - if (!$res) { - error_log('Could not create IMAP folder $f: ' . $this->id . ': ' . imap_last_error()); - @imap_close($i); - return false; - } - @imap_subscribe($i, $f); - } + // see https://github.com/postfixadmin/postfixadmin/issues/472 + // see https://github.com/postfixadmin/postfixadmin/issues/812 etc + error_log(__FILE__ . ' WARNING : PostfixAdmin no longer supports the imap folder population via config parameters: create_mailbox_subdirs, create_mailbox_subdirs_host, create_mailbox_subdirs_hostport and create_mailbox_subdirs_hostoptions '); - @imap_close($i); return true; } diff --git a/public/setup.php b/public/setup.php index d1d84480..2960d01f 100644 --- a/public/setup.php +++ b/public/setup.php @@ -573,7 +573,6 @@ function do_software_environment_check() $f_session_start = function_exists("session_start"); $f_preg_match = function_exists("preg_match"); $f_mb_encode_mimeheader = function_exists("mb_encode_mimeheader"); - $f_imap_open = function_exists("imap_open"); $file_local_config = realpath(__DIR__ . "/../config.local.php"); @@ -727,13 +726,5 @@ function do_software_environment_check() } - // Imap functions - if ($f_imap_open) { - $info[] = "Optional - PHP IMAP functions - OK"; - } else { - $warn[] = "Warning: Optional dependency - PHP 'imap' extension missing. Without this you may not be able to automate creation of sub-folders for new mailboxes"; - } - - return ['error' => $error, 'warn' => $warn, 'info' => $info]; }