Voicemail-to-Email: Domain Settings fix.

This commit is contained in:
Nate 2019-12-11 15:59:15 -07:00
parent 5f20080c66
commit aaca2bb47c
1 changed files with 12 additions and 8 deletions

View File

@ -73,6 +73,9 @@
ob_end_clean(); ob_end_clean();
ob_start(); ob_start();
//message divider for log file
echo "\n\n======================================================================================================================================================================================\n\n";
//testing show the raw email //testing show the raw email
//echo "Message: \n".$msg."\n"; //echo "Message: \n".$msg."\n";
@ -99,6 +102,7 @@
// 'SkipBody' => 1, // 'SkipBody' => 1,
); );
$success = $mime->Decode($parameters, $decoded); $success = $mime->Decode($parameters, $decoded);
unset($parameters);
if (!$success) { if (!$success) {
echo "MIME message decoding error: ".HtmlSpecialChars($mime->error)."\n"; echo "MIME message decoding error: ".HtmlSpecialChars($mime->error)."\n";
@ -142,7 +146,7 @@
} }
$smtp['host'] = (strlen($_SESSION['email']['smtp_host']['text'])?$_SESSION['email']['smtp_host']['text']:'127.0.0.1'); $smtp['host'] = (strlen($_SESSION['email']['smtp_host']['text'])?$_SESSION['email']['smtp_host']['text']:'127.0.0.1');
if (isset($_SESSION['email']['smtp_port'])) { if (isset($_SESSION['email']['smtp_port'])) {
$smtp['port'] = (int)$_SESSION['email']['smtp_port']['numeric']; $smtp['port'] = (int) $_SESSION['email']['smtp_port']['numeric'];
} }
else { else {
$smtp['port'] = 0; $smtp['port'] = 0;
@ -162,12 +166,11 @@
} }
// overwrite with domain-specific smtp server settings, if any // overwrite with domain-specific smtp server settings, if any
if ($headers["X-FusionPBX-Domain-UUID"] != '') { if (is_uuid($headers["X-FusionPBX-Domain-UUID"])) {
$sql = "select domain_setting_subcategory, domain_setting_value "; $sql = "select domain_setting_subcategory, domain_setting_value ";
$sql .= "from v_domain_settings "; $sql .= "from v_domain_settings ";
$sql .= "where domain_uuid = :domain_uuid "; $sql .= "where domain_uuid = :domain_uuid ";
$sql .= "and (domain_setting_category = 'email' or domain_setting_category = 'voicemail') "; $sql .= "and (domain_setting_category = 'email' or domain_setting_category = 'voicemail') ";
$sql .= "and domain_setting_name = 'text' ";
$sql .= "and domain_setting_enabled = 'true' "; $sql .= "and domain_setting_enabled = 'true' ";
$parameters['domain_uuid'] = $headers["X-FusionPBX-Domain-UUID"]; $parameters['domain_uuid'] = $headers["X-FusionPBX-Domain-UUID"];
$database = new database; $database = new database;
@ -192,7 +195,7 @@
include_once "resources/phpmailer/class.smtp.php"; include_once "resources/phpmailer/class.smtp.php";
$mail = new PHPMailer(); $mail = new PHPMailer();
if (isset($_SESSION['email']['method'])) { if (isset($_SESSION['email']['method'])) {
switch($_SESSION['email']['method']['text']) { switch ($_SESSION['email']['method']['text']) {
case 'sendmail': $mail->IsSendmail(); break; case 'sendmail': $mail->IsSendmail(); break;
case 'qmail': $mail->IsQmail(); break; case 'qmail': $mail->IsQmail(); break;
case 'mail': $mail->IsMail(); break; case 'mail': $mail->IsMail(); break;
@ -273,7 +276,7 @@
//get the attachments and add to the email //get the attachments and add to the email
if ($success) { if ($success) {
foreach ($decoded[0][Parts] as &$parts_array) { foreach ($decoded[0]["Parts"] as &$parts_array) {
$content_type = $parts_array["Parts"][0]["Headers"]["content-type:"]; $content_type = $parts_array["Parts"][0]["Headers"]["content-type:"];
//image/tiff;name="testfax.tif" //image/tiff;name="testfax.tif"
//text/plain; charset=ISO-8859-1; format=flowed //text/plain; charset=ISO-8859-1; format=flowed
@ -294,7 +297,7 @@
$file_name = substr($file, 0, (strlen($file) - strlen($file_ext))-1 ); $file_name = substr($file, 0, (strlen($file) - strlen($file_ext))-1 );
$encoding = "base64"; //base64_decode $encoding = "base64"; //base64_decode
switch($file_ext){ switch ($file_ext){
case "wav": case "wav":
$mime_type = "audio/x-wav"; $mime_type = "audio/x-wav";
break; break;
@ -317,11 +320,12 @@
//add an attachment //add an attachment
$mail->AddStringAttachment($parts_array["Body"],$file,$encoding,$mime_type); $mail->AddStringAttachment($parts_array["Body"],$file,$encoding,$mime_type);
if (function_exists(get_transcription)) { if (function_exists('get_transcription')) {
$attachments_array = $mail->GetAttachments(); $attachments_array = $mail->GetAttachments();
$transcription = get_transcription($attachments_array[0]); $transcription = get_transcription($attachments_array[0]);
echo "Transcription: " . $transcription; echo "Transcription: " . $transcription;
} else { }
else {
$transcription = ''; $transcription = '';
} }
} }