SMTPAuth change from string to boolean true or false.

- Build the SMPTOptions array in a more flexible way
- And add an SMPT pption to set the crypto_method
This commit is contained in:
FusionPBX 2022-01-31 12:27:44 -07:00 committed by GitHub
parent b758962ec1
commit 158391c5ec
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 18 additions and 10 deletions

View File

@ -1392,12 +1392,12 @@ function number_pad($number,$n) {
$mail->Port = $_SESSION['email']['smtp_port']['numeric'];
}
if ($_SESSION['email']['smtp_auth']['text'] == "true") {
$mail->SMTPAuth = $_SESSION['email']['smtp_auth']['text'];
$mail->SMTPAuth = true;
$mail->Username = $_SESSION['email']['smtp_username']['text'];
$mail->Password = $_SESSION['email']['smtp_password']['text'];
}
else {
$mail->SMTPAuth = 'false';
$mail->SMTPAuth = false;
}
if ($_SESSION['email']['smtp_secure']['text'] == "none") {
$_SESSION['email']['smtp_secure']['text'] = '';
@ -1405,16 +1405,24 @@ function number_pad($number,$n) {
if ($_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") {
// bypass TLS certificate check e.g. for self-signed certificates
$mail->SMTPOptions = array(
'ssl' => array(
'verify_peer' => false,
'verify_peer_name' => false,
'allow_self_signed' => true
)
);
//bypass certificate check e.g. for self-signed certificates
$smtp_options['ssl']['verify_peer'] = false;
$smtp_options['ssl']['verify_peer_name'] = false;
$smtp_options['ssl']['allow_self_signed'] = true;
}
//used to set the SSL version
if (isset($_SESSION['email']['smtp_crypto_method'])) {
$smtp_options['ssl']['crypto_method'] = $_SESSION['email']['smtp_crypto_method']['text'];
}
//add SMTP Options if the array exists
if (is_array($smtp_options)) {
$mail->SMTPOptions = $smtp_options;
}
$eml_from_address = ($eml_from_address != '') ? $eml_from_address : $_SESSION['email']['smtp_from']['text'];
$eml_from_name = ($eml_from_name != '') ? $eml_from_name : $_SESSION['email']['smtp_from_name']['text'];
$mail->SetFrom($eml_from_address, $eml_from_name);