function hesk_testSMTP() { global $hesk_settings, $hesklang, $set; // Get variables $set['smtp_host_name'] = hesk_input(hesk_POST('s_smtp_host_name', 'localhost')); $set['smtp_host_port'] = intval(hesk_POST('s_smtp_host_port', 25)); $set['smtp_timeout'] = intval(hesk_POST('s_smtp_timeout', 10)); $set['smtp_ssl'] = empty($_POST['s_smtp_ssl']) ? 0 : 1; $set['smtp_tls'] = empty($_POST['s_smtp_tls']) ? 0 : 1; $set['smtp_user'] = hesk_input(hesk_POST('s_smtp_user')); $set['smtp_password'] = hesk_input(hesk_POST('s_smtp_password')); // Initiate SMTP class and set parameters require_once HESK_PATH . 'inc/mail/smtp.php'; $smtp = new smtp_class(); $smtp->host_name = $set['smtp_host_name']; $smtp->host_port = $set['smtp_host_port']; $smtp->timeout = $set['smtp_timeout']; $smtp->ssl = $set['smtp_ssl']; $smtp->start_tls = $set['smtp_tls']; $smtp->user = $set['smtp_user']; $smtp->password = hesk_htmlspecialchars_decode(stripslashes($set['smtp_password'])); $smtp->debug = 1; if (strlen($set['smtp_user']) || strlen($set['smtp_password'])) { require_once HESK_PATH . 'inc/mail/sasl/sasl.php'; } $connection_OK = false; ob_start(); // Test connection if ($smtp->Connect()) { // SMTP connect successful $connection_OK = true; $smtp->Disconnect(); } else { global $smtp_error, $smtp_log; $smtp_error = ucfirst($smtp->error); $smtp_log = ob_get_contents(); } $smtp_log = ob_get_contents(); ob_end_clean(); return $connection_OK; }