Adjust smtp_secure to work better when not using TLS.

This commit is contained in:
FusionPBX
2022-02-28 13:43:04 -07:00
committed by GitHub
parent 66f255835a
commit 85778bd3ec
+15 -5
View File
@@ -1382,6 +1382,7 @@ function number_pad($number,$n) {
if (is_numeric($_SESSION['email']['smtp_port']['numeric'])) { if (is_numeric($_SESSION['email']['smtp_port']['numeric'])) {
$mail->Port = $_SESSION['email']['smtp_port']['numeric']; $mail->Port = $_SESSION['email']['smtp_port']['numeric'];
} }
if ($_SESSION['email']['smtp_auth']['text'] == "true") { if ($_SESSION['email']['smtp_auth']['text'] == "true") {
$mail->SMTPAuth = true; $mail->SMTPAuth = true;
$mail->Username = $_SESSION['email']['smtp_username']['text']; $mail->Username = $_SESSION['email']['smtp_username']['text'];
@@ -1390,14 +1391,23 @@ function number_pad($number,$n) {
else { else {
$mail->SMTPAuth = false; $mail->SMTPAuth = false;
} }
if ($_SESSION['email']['smtp_secure']['text'] == "none") {
$_SESSION['email']['smtp_secure']['text'] = ''; $smtp_secure = true;
if ($_SESSION['email']['smtp_secure']['text'] == "") {
$mail->SMTPSecure = 'none';
$mail->SMTPAutoTLS = false;
$smtp_secure = false;
} }
if ($_SESSION['email']['smtp_secure']['text'] != '') { elseif ($_SESSION['email']['smtp_secure']['text'] == "none") {
$mail->SMTPSecure = 'none';
$mail->SMTPAutoTLS = false;
$smtp_secure = false;
}
else {
$mail->SMTPSecure = $_SESSION['email']['smtp_secure']['text']; $mail->SMTPSecure = $_SESSION['email']['smtp_secure']['text'];
} }
if (isset($_SESSION['email']['smtp_validate_certificate']) && $_SESSION['email']['smtp_validate_certificate']['boolean'] == "false") { if ($smtp_secure && isset($_SESSION['email']['smtp_validate_certificate']) && $_SESSION['email']['smtp_validate_certificate']['boolean'] == "false") {
//bypass certificate check e.g. for self-signed certificates //bypass certificate check e.g. for self-signed certificates
$smtp_options['ssl']['verify_peer'] = false; $smtp_options['ssl']['verify_peer'] = false;
$smtp_options['ssl']['verify_peer_name'] = false; $smtp_options['ssl']['verify_peer_name'] = false;
@@ -1405,7 +1415,7 @@ function number_pad($number,$n) {
} }
//used to set the SSL version //used to set the SSL version
if (isset($_SESSION['email']['smtp_crypto_method'])) { if ($smtp_secure && isset($_SESSION['email']['smtp_crypto_method'])) {
$smtp_options['ssl']['crypto_method'] = $_SESSION['email']['smtp_crypto_method']['text']; $smtp_options['ssl']['crypto_method'] = $_SESSION['email']['smtp_crypto_method']['text'];
} }