From aaca2bb47c1ee655bbc3b0d37b1de099bb0e0913 Mon Sep 17 00:00:00 2001 From: Nate Date: Wed, 11 Dec 2019 15:59:15 -0700 Subject: [PATCH] Voicemail-to-Email: Domain Settings fix. --- secure/v_mailto.php | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/secure/v_mailto.php b/secure/v_mailto.php index 97cf6b9aa0..c4c06bcfc6 100755 --- a/secure/v_mailto.php +++ b/secure/v_mailto.php @@ -73,6 +73,9 @@ ob_end_clean(); ob_start(); +//message divider for log file + echo "\n\n======================================================================================================================================================================================\n\n"; + //testing show the raw email //echo "Message: \n".$msg."\n"; @@ -99,6 +102,7 @@ // 'SkipBody' => 1, ); $success = $mime->Decode($parameters, $decoded); + unset($parameters); if (!$success) { 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'); if (isset($_SESSION['email']['smtp_port'])) { - $smtp['port'] = (int)$_SESSION['email']['smtp_port']['numeric']; + $smtp['port'] = (int) $_SESSION['email']['smtp_port']['numeric']; } else { $smtp['port'] = 0; @@ -162,12 +166,11 @@ } // 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 .= "from v_domain_settings "; $sql .= "where domain_uuid = :domain_uuid "; $sql .= "and (domain_setting_category = 'email' or domain_setting_category = 'voicemail') "; - $sql .= "and domain_setting_name = 'text' "; $sql .= "and domain_setting_enabled = 'true' "; $parameters['domain_uuid'] = $headers["X-FusionPBX-Domain-UUID"]; $database = new database; @@ -192,7 +195,7 @@ include_once "resources/phpmailer/class.smtp.php"; $mail = new PHPMailer(); if (isset($_SESSION['email']['method'])) { - switch($_SESSION['email']['method']['text']) { + switch ($_SESSION['email']['method']['text']) { case 'sendmail': $mail->IsSendmail(); break; case 'qmail': $mail->IsQmail(); break; case 'mail': $mail->IsMail(); break; @@ -273,7 +276,7 @@ //get the attachments and add to the email 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:"]; //image/tiff;name="testfax.tif" //text/plain; charset=ISO-8859-1; format=flowed @@ -294,7 +297,7 @@ $file_name = substr($file, 0, (strlen($file) - strlen($file_ext))-1 ); $encoding = "base64"; //base64_decode - switch($file_ext){ + switch ($file_ext){ case "wav": $mime_type = "audio/x-wav"; break; @@ -317,11 +320,12 @@ //add an attachment $mail->AddStringAttachment($parts_array["Body"],$file,$encoding,$mime_type); - if (function_exists(get_transcription)) { + if (function_exists('get_transcription')) { $attachments_array = $mail->GetAttachments(); $transcription = get_transcription($attachments_array[0]); echo "Transcription: " . $transcription; - } else { + } + else { $transcription = ''; } }