forked from fusionpbx/fusionpbx
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
0f3a214
commit fa50cd8
Showing
1 changed file
with
59 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -357,6 +357,48 @@ function fax_split_dtmf(&$fax_number, &$fax_dtmf){ | |
} | ||
unset ($prep_statement); | ||
|
||
//prepare smtp server settings | ||
// load default smtp settings | ||
$smtp['host'] = (strlen($_SESSION['email']['smtp_host']['var'])?$_SESSION['email']['smtp_host']['var']:'127.0.0.1'); | ||
if (isset($_SESSION['email']['smtp_port'])) { | ||
$smtp['port'] = (int)$_SESSION['email']['smtp_port']['numeric']; | ||
} else { | ||
$smtp['port'] = 0; | ||
} | ||
$smtp['secure'] = $_SESSION['email']['smtp_secure']['var']; | ||
$smtp['auth'] = $_SESSION['email']['smtp_auth']['var']; | ||
$smtp['username'] = $_SESSION['email']['smtp_username']['var']; | ||
$smtp['password'] = $_SESSION['email']['smtp_password']['var']; | ||
$smtp['from'] = (strlen($_SESSION['email']['smtp_from']['var'])?$_SESSION['email']['smtp_from']['var']:'[email protected]'); | ||
$smtp['from_name'] = (strlen($_SESSION['email']['smtp_from_name']['var'])?$_SESSION['email']['smtp_from_name']['var']:'FusionPBX FAX'); | ||
|
||
// overwrite with domain-specific smtp server settings, if any | ||
if ($domain_uuid != '') { | ||
$sql = "select domain_setting_subcategory, domain_setting_value "; | ||
$sql .= "from v_domain_settings "; | ||
$sql .= "where domain_uuid = '".$domain_uuid."' "; | ||
$sql .= "and domain_setting_category = 'email' "; | ||
$sql .= "and domain_setting_name = 'var' "; | ||
$sql .= "and domain_setting_enabled = 'true' "; | ||
$prep_statement = $db->prepare($sql); | ||
if ($prep_statement) { | ||
$prep_statement->execute(); | ||
$result = $prep_statement->fetchAll(PDO::FETCH_NAMED); | ||
foreach ($result as $row) { | ||
if ($row['domain_setting_value'] != '') { | ||
$smtp[str_replace('smtp_','',$row["domain_setting_subcategory"])] = $row['domain_setting_value']; | ||
} | ||
} | ||
} | ||
unset($sql, $prep_statement); | ||
} | ||
|
||
// value adjustments | ||
$smtp['auth'] = ($smtp['auth'] == "true") ? true : false; | ||
$smtp['password'] = ($smtp['password'] != '') ? $smtp['password'] : null; | ||
$smtp['secure'] = ($smtp['secure'] != "none") ? $smtp['secure'] : null; | ||
$smtp['username'] = ($smtp['username'] != '') ? $smtp['username'] : null; | ||
|
||
//get the fax details from the database | ||
$sql = "select * from v_fax "; | ||
$sql .= "where domain_uuid = '".$_SESSION["domain_uuid"]."' "; | ||
|
@@ -518,8 +560,8 @@ function fax_split_dtmf(&$fax_number, &$fax_dtmf){ | |
|
||
//prepare the mail object | ||
$mail = new PHPMailer(); | ||
if (isset($_SESSION['email']['method'])) { | ||
switch($_SESSION['email']['method']['text']) { | ||
if (isset($smtp['method'])) { | ||
switch($smtp['method']) { | ||
case 'sendmail': $mail->IsSendmail(); break; | ||
case 'qmail': $mail->IsQmail(); break; | ||
case 'mail': $mail->IsMail(); break; | ||
|
@@ -529,23 +571,23 @@ function fax_split_dtmf(&$fax_number, &$fax_dtmf){ | |
else { | ||
$mail->IsSMTP(); // set mailer to use SMTP | ||
} | ||
if ($_SESSION['email']['smtp_auth']['var'] == "true") { | ||
$mail->SMTPAuth = $_SESSION['email']['smtp_auth']['var']; // turn on/off SMTP authentication | ||
if ($smtp['auth'] == "true") { | ||
$mail->SMTPAuth = $smtp['auth']; // turn on/off SMTP authentication | ||
} | ||
$mail->Host = $_SESSION['email']['smtp_host']['var']; | ||
if (strlen($_SESSION['email']['smtp_port']['var']) > 0) { | ||
$mail->Port = $_SESSION['email']['smtp_port']['var']; | ||
$mail->Host = $smtp['host']; | ||
if (strlen($smtp['port']) > 0) { | ||
$mail->Port = $smtp['port']; | ||
} | ||
if (strlen($_SESSION['email']['smtp_secure']['var']) > 0 && $_SESSION['email']['smtp_secure']['var'] != 'none') { | ||
$mail->SMTPSecure = $_SESSION['email']['smtp_secure']['var']; | ||
if (strlen($smtp['secure']) > 0 && $smtp['secure'] != 'none') { | ||
$mail->SMTPSecure = $smtp['secure']; | ||
} | ||
if ($_SESSION['email']['smtp_username']['var'] != '') { | ||
$mail->Username = $_SESSION['email']['smtp_username']['var']; | ||
$mail->Password = $_SESSION['email']['smtp_password']['var']; | ||
if ($smtp['username'] != '') { | ||
$mail->Username = $smtp['username']; | ||
$mail->Password = $smtp['password']; | ||
} | ||
$mail->SMTPDebug = 2; | ||
$mail->From = $_SESSION['email']['smtp_from']['var']; | ||
$mail->FromName = $_SESSION['email']['smtp_from_name']['var']; | ||
$mail->From = $smtp['from']; | ||
$mail->FromName = $smtp['from_name']; | ||
$mail->Subject = $tmp_subject; | ||
$mail->AltBody = $tmp_text_plain; | ||
$mail->MsgHTML($tmp_text_html); | ||
|
@@ -561,9 +603,9 @@ function fax_split_dtmf(&$fax_number, &$fax_dtmf){ | |
} | ||
|
||
//output to the log | ||
echo "smtp_host: ".$_SESSION['email']['smtp_host']['var']."\n"; | ||
echo "smtp_from: ".$_SESSION['email']['smtp_from']['var']."\n"; | ||
echo "smtp_from_name: ".$_SESSION['email']['smtp_from_name']['var']."\n"; | ||
echo "smtp_host: ".$smtp['host']."\n"; | ||
echo "smtp_from: ".$smtp['from']."\n"; | ||
echo "smtp_from_name: ".$smtp['from_name']."\n"; | ||
echo "tmp_subject: $tmp_subject\n"; | ||
|
||
//add the attachments | ||
|