Skip to content

Commit

Permalink
Removed POP3 support
Browse files Browse the repository at this point in the history
  • Loading branch information
josaphatim committed Apr 20, 2023
1 parent b164246 commit 30f3da0
Show file tree
Hide file tree
Showing 34 changed files with 37 additions and 2,495 deletions.
34 changes: 4 additions & 30 deletions .travis/hm3.ini
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,7 @@ session_type=PHP
; 3 PHP cli scripts to help manage database users in the scripts/ directory (
; create_account.php, delete_account.php, and update_password.php). If you want
; to authenticate against an IMAP server, you must setup the imap_auth_* settings
; below. If you want to authenticate against a POP3 server, you must setup the
; pop3_auth_* settings below. If you want to authenticate against an LDAP server,
; below. If you want to authenticate against an LDAP server,
; you must setup the ldap_auth_* settings. Finally, if you want to let users
; pick from a list of popular mail services or try to auto-discover a mail
; system, set this to dynamic and make sure the dynamic_login module set is
Expand All @@ -42,7 +41,6 @@ session_type=PHP
; DB Authenticate against the database
; LDAP Authenticate against an LDAP server
; IMAP Authenticate using an IMAP server
; POP3 Authenticate using a POP3 server
; dynamic Let the user choose from a list, or try to auto discover the mail
; services based on the E-mail domain
;
Expand Down Expand Up @@ -89,30 +87,11 @@ imap_auth_port=143
imap_auth_tls=false


; POP3 Authentication
; -------------------
; if auth_type is set to POP3, configure the POP3 server to authenticate against
; with the following settings, otherwise these are ignored.
;
; This is just a label used in the UI. It can be set to anything
pop3_auth_name=localhost

; The hostname or IP address of the POP3 server to authenticate to
pop3_auth_server=localhost

; The port the POP3 server is listening on.
pop3_auth_port=110

; Enable TLS/SSL connections. Leave blank or set to false to disable. Set to
; true to enable TLS connections.
pop3_auth_tls=


; Default SMTP Server
; -------------------
; You can set a default SMTP server for all Cypht users. Authentication will be
; done with the users login credentials, so this only makes sense if you are
; using POP3 or IMAP for authentication. Leave these values blank to disable a
; using IMAP for authentication. Leave these values blank to disable a
; default SMTP server, otherwise fill in the required values below
;
; This is just a label used in the UI. It can be set to anything
Expand Down Expand Up @@ -202,7 +181,7 @@ disable_origin_check=false
; special rights to. Currently this only enables the "create account" link in
; the account module set that provides a form to create a new account. This is
; only used if the auth_type is set to DB. Leave this blank if you don't want
; to define any admin users, or are using IMAP or POP3 authentication.
; to define any admin users, or are using IMAP authentication.
admin_users=


Expand Down Expand Up @@ -427,11 +406,6 @@ modules[]=local_contacts
; RSS/ATOM feed support
modules[]=feeds

; POP3
; ----
; POP3 E-mail account support
modules[]=pop3

; IMAP
; ----
; IMAP E-mail account support. If you want to use Oauth2 over IMAP (currently
Expand Down Expand Up @@ -564,7 +538,7 @@ modules[]=keyboard_shortcuts

; Recover settings
; ----------------
; When using IMAP or POP3 authentication, if a user's password is changed, we
; When using IMAP authentication, if a user's password is changed, we
; can't decrypt the existing user settings. This module detects that situation
; and provides a page where a user can enter their old and new passwords to
; recover their previous settings.
Expand Down
40 changes: 7 additions & 33 deletions hm3.sample.ini
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,7 @@ session_type=PHP
; 3 PHP cli scripts to help manage database users in the scripts/ directory (
; create_account.php, delete_account.php, and update_password.php). If you want
; to authenticate against an IMAP server, you must setup the imap_auth_* settings
; below. If you want to authenticate against a POP3 server, you must setup the
; pop3_auth_* settings below. If you want to authenticate against an LDAP server,
; below. If you want to authenticate against an LDAP server,
; you must setup the ldap_auth_* settings. Finally, if you want to let users
; pick from a list of popular mail services or try to auto-discover a mail
; system, set this to dynamic and make sure the dynamic_login module set is
Expand All @@ -46,7 +45,6 @@ session_type=PHP
; DB Authenticate against the database
; LDAP Authenticate against an LDAP server
; IMAP Authenticate using an IMAP server
; POP3 Authenticate using a POP3 server
; dynamic Let the user choose from a list, or try to auto discover the mail
; services based on the email domain
; custom Create your own auth class. See the modules/site/lib.php file for
Expand Down Expand Up @@ -98,30 +96,11 @@ imap_auth_tls=
imap_auth_sieve_conf_host=


; POP3 Authentication
; -------------------
; if auth_type is set to POP3, configure the POP3 server to authenticate against
; with the following settings, otherwise these are ignored.
;
; This is just a label used in the UI. It can be set to anything
pop3_auth_name=localhost

; The hostname or IP address of the POP3 server to authenticate to
pop3_auth_server=localhost

; The port the POP3 server is listening on.
pop3_auth_port=110

; Enable TLS/SSL connections. Leave blank or set to false to disable. Set to
; true to enable TLS connections.
pop3_auth_tls=


; Default SMTP Server
; -------------------
; You can set a default SMTP server for all Cypht users. Authentication will be
; done with the users login credentials, so this only makes sense if you are
; using POP3 or IMAP for authentication. Leave these values blank to disable a
; using IMAP for authentication. Leave these values blank to disable a
; default SMTP server, otherwise fill in the required values below
;
; This is just a label used in the UI. It can be set to anything
Expand Down Expand Up @@ -200,7 +179,7 @@ disable_origin_check=false
; special rights to. Currently this only enables the "create account" link in
; the account module set that provides a form to create a new account. This is
; only used if the auth_type is set to DB. Leave this blank if you don't want
; to define any admin users, or are using IMAP or POP3 authentication.
; to define any admin users, or are using IMAP authentication.
admin_users=


Expand Down Expand Up @@ -315,7 +294,7 @@ css_compress=false
; Cypht can use Redis or Memcache to improve performance, as well as to store
; user sessions. Configure Redis or Memcached below and Cypht will
; automatically use them for caching. All data cached for a user in either
; system is encrypted. Currently, the feeds, POP3, and IMAP modules will use
; system is encrypted. Currently, the feeds, and IMAP modules will use
; the configured cache. If both Redis and Memcached are configured, Redis will
; be used for the cache.
;
Expand Down Expand Up @@ -420,10 +399,10 @@ allow_external_image_sources=false
;
; Single server mode
; ------------------
; This setting restricts Cypht to only using a single email source (POP3 or
; This setting restricts Cypht to only using a single email source (
; IMAP) and the default SMTP server defined in this file. It modifies the UI to
; remove the ability to add other email sources, and removes the password
; restriction when saving data between logins. You must use either IMAP or POP3
; restriction when saving data between logins. You must use either IMAP
; authentication for this setting to be enforced, and auth server will be the
; single email source users have access to. If you enable this after users
; have saved any settings, they will be lost (or if you disable it after they
Expand Down Expand Up @@ -580,11 +559,6 @@ modules[]=local_contacts
; RSS/ATOM feed support
modules[]=feeds

; POP3
; ----
; POP3 email account support
modules[]=pop3

; JMAP
; ----
; JSON Meta Application Protocol for emails
Expand Down Expand Up @@ -742,7 +716,7 @@ modules[]=keyboard_shortcuts

; Recover settings
; ----------------
; When using IMAP or POP3 authentication, if a user's password is changed, we
; When using IMAP, if a user's password is changed, we
; can't decrypt the existing user settings. This module detects that situation
; and provides a page where a user can enter their old and new passwords to
; recover their previous settings.
Expand Down
76 changes: 0 additions & 76 deletions lib/auth.php
Original file line number Diff line number Diff line change
Expand Up @@ -214,82 +214,6 @@ public function save_auth_detail($session) {
}
}

/**
* Authenticate against a POP3 server
*/
class Hm_Auth_POP3 extends Hm_Auth {

/* POP3 authentication server settings */
private $pop3_settings = array();

/**
* Assign site config, get required libs
* @param object $config site config
*/
public function __construct($config) {
$this->site_config = $config;
require_once APP_PATH.'modules/pop3/hm-pop3.php';
}

/**
* @param object $pop3 pop3 connection object
* @param string $user username to login with
* @param string $pass password to login with
* @param string $server server to login to
* @return boolean
*/
private function check_connection($pop3, $user, $pass, $server) {
if (!$pop3->connect()) {
Hm_Debug::add($pop3->puke());
Hm_Debug::add(sprintf('Unable to connect to the POP3 auth server %s', $server));
return false;
}
if (!$pop3->auth($user, $pass)) {
Hm_Debug::add($pop3->puke());
Hm_Debug::add(sprintf('POP3 AUTH failed for %s', $user));
return false;
}
return true;
}

/**
* Send the username and password to the configured POP3 server for authentication
* @param string $user username
* @param string $pass password
* @return bool true if authentication worked
*/
public function check_credentials($user, $pass) {
$pop3 = new Hm_POP3();
list($server, $port, $tls) = get_auth_config($this->site_config, 'pop3');
if ($user && $pass && $server && $port) {
$this->pop3_settings = array(
'server' => $server,
'port' => $port,
'tls' => $tls,
'username' => $user,
'password' => $pass,
'no_caps' => true
);
$pop3->server = $server;
$pop3->port = $port;
$pop3->tls = $tls;
return $this->check_connection($pop3, $user, $pass, $server);
}
Hm_Debug::add($pop3->puke());
Hm_Debug::add('Invalid POP3 auth configuration settings');
return false;
}

/**
* Save POP3 server details
* @param object $session session object
* @return void
*/
public function save_auth_detail($session) {
$session->set('pop3_auth_server_settings', $this->pop3_settings);
}
}

/**
* Authenticate against an LDAP server
*/
Expand Down
2 changes: 1 addition & 1 deletion lib/cache.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

/**
* Helper struct to provide data sources the don't track messages read or flagged state
* (like POP3 or RSS) with an alternative.
* (like RSS) with an alternative.
* @package framework
* @subpackage cache
*/
Expand Down
7 changes: 2 additions & 5 deletions lib/config.php
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,6 @@ public function reset_factory() {
$this->config = array(
"version"=>$this->config["version"],
"feeds"=>$this->config["feeds"],
"pop3_servers"=>$this->config["pop3_servers"],
"imap_servers"=>$this->config["imap_servers"],
"smtp_servers"=>$this->config["smtp_servers"]
);
Expand Down Expand Up @@ -142,7 +141,7 @@ public function decode($data) {
*/
public function filter_servers() {
$removed = array();
$excluded = array('pop3_servers', 'imap_servers','smtp_servers');
$excluded = array('imap_servers','smtp_servers');
$no_password = $this->get('no_password_save_setting', false);
foreach ($this->config as $key => $vals) {
if (in_array($key, $excluded, true)) {
Expand Down Expand Up @@ -306,7 +305,6 @@ public function reset_factory() {
$this->config = array(
"version"=>$this->config["version"],
"feeds"=>$this->config["feeds"],
"pop3_servers"=>$this->config["pop3_servers"],
"imap_servers"=>$this->config["imap_servers"],
"smtp_servers"=>$this->config["smtp_servers"]
);
Expand Down Expand Up @@ -461,7 +459,6 @@ public function reset_factory() {
$this->config = array(
"version"=>$this->config["version"],
"feeds"=>$this->config["feeds"],
"pop3_servers"=>$this->config["pop3_servers"],
"imap_servers"=>$this->config["imap_servers"],
"smtp_servers"=>$this->config["smtp_servers"]
);
Expand Down Expand Up @@ -565,7 +562,7 @@ function load_user_config_object($config) {
*/
function crypt_state($config) {
if ($config->get('single_server_mode') &&
in_array($config->get('auth_type'), array('IMAP', 'POP3'), true)) {
in_array($config->get('auth_type'), array('IMAP'), true)) {
return false;
}
return true;
Expand Down
2 changes: 1 addition & 1 deletion lib/dispatch.php
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,7 @@ private function save_settings_on_login() {
* @return void
*/
private function close_connections() {
foreach (array('Hm_IMAP_List', 'Hm_POP3_List', 'Hm_SMTP_List') as $class) {
foreach (array('Hm_IMAP_List', 'Hm_SMTP_List') as $class) {
if (Hm_Functions::class_exists($class)) {
$class::clean_up();
}
Expand Down
2 changes: 1 addition & 1 deletion lib/modules.php
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ public static function load($mod_list) {

/**
* Assign the module set name
* @param string $source the name of the module set (imap, pop3, core, etc)
* @param string $source the name of the module set (imap, core, etc)
* @return void
*/
public static function set_source($source) {
Expand Down
2 changes: 1 addition & 1 deletion lib/session_base.php
Original file line number Diff line number Diff line change
Expand Up @@ -461,7 +461,7 @@ private function dynamic_auth() {
* @return string|false
*/
private function standard_auth() {
if ($this->auth_type && in_array($this->auth_type, array('DB', 'LDAP', 'IMAP', 'POP3'), true)) {
if ($this->auth_type && in_array($this->auth_type, array('DB', 'LDAP', 'IMAP'), true)) {
return sprintf('Hm_Auth_%s', $this->auth_type);
}
return false;
Expand Down
4 changes: 2 additions & 2 deletions modules/core/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ The core module set handles page layout, authentication, the main menu, and the
default settings pages. It is the only required module set to run Cypht.

Technically you can disable every other module set in Cypht and still login
(assuming you are not using IMAP or POP3 authentication). Doing so gives you a
(assuming you are not using IMAP authentication). Doing so gives you a
very limited main menu, the combined pages (unread, flagged, everything,
search), all of which will have no content since that is all handled by other
module sets, and the settings pages with limited options.

This set also contains many helper functions for other module sets to use that
don't really "fit" into the framework proper.
don't really "fit" into the framework proper.
2 changes: 1 addition & 1 deletion modules/core/functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ function group_data_sources($array) {
*/
if (!hm_exists('email_is_active')) {
function email_is_active($mod_list) {
if (in_array('imap', $mod_list, true) || in_array('pop3', $mod_list, true)) {
if (in_array('imap', $mod_list, true)) {
return true;
}
return false;
Expand Down
Loading

0 comments on commit 30f3da0

Please sign in to comment.