0
0
mirror of https://github.com/postfixadmin/postfixadmin.git synced 2024-09-19 11:12:15 +02:00

drop use of the deprecated PHP imap extension (php-imap) - see #472 and #812

This commit is contained in:
David Goodwin 2024-04-01 19:32:27 +01:00
parent 582680889e
commit 81a1d45617
4 changed files with 6 additions and 80 deletions

View File

@ -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 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 5. Check settings, and create Admin user
---------------------------------------- ----------------------------------------

2
debian/control vendored
View File

@ -11,7 +11,7 @@ Homepage: http://postfixadmin.sourceforge.net
Package: postfixadmin Package: postfixadmin
Architecture: all 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 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 Description: Virtual mail hosting interface for Postfix
Postfixadmin is a web interface to manage virtual users and domains Postfixadmin is a web interface to manage virtual users and domains

View File

@ -749,76 +749,17 @@ class MailboxHandler extends PFAHandler
*/ */
protected function create_mailbox_subfolders() protected function create_mailbox_subfolders()
{ {
// no longer implemented; code relied on deprecated PHP imap extension.
$create_mailbox_subdirs = Config::read('create_mailbox_subdirs'); $create_mailbox_subdirs = Config::read('create_mailbox_subdirs');
if (empty($create_mailbox_subdirs)) { if (empty($create_mailbox_subdirs)) {
return true; return true;
} }
if (!function_exists('imap_open')) { // see https://github.com/postfixadmin/postfixadmin/issues/472
trigger_error('imap_open function not present; cannot create_mailbox_subdirs'); // see https://github.com/postfixadmin/postfixadmin/issues/812 etc
return false; 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 ');
}
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);
}
@imap_close($i);
return true; return true;
} }

View File

@ -573,7 +573,6 @@ function do_software_environment_check()
$f_session_start = function_exists("session_start"); $f_session_start = function_exists("session_start");
$f_preg_match = function_exists("preg_match"); $f_preg_match = function_exists("preg_match");
$f_mb_encode_mimeheader = function_exists("mb_encode_mimeheader"); $f_mb_encode_mimeheader = function_exists("mb_encode_mimeheader");
$f_imap_open = function_exists("imap_open");
$file_local_config = realpath(__DIR__ . "/../config.local.php"); $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]; return ['error' => $error, 'warn' => $warn, 'info' => $info];
} }