Add email attachment cid and mime type

This commit is contained in:
markjcrane
2023-04-12 14:04:56 -06:00
parent a5d2558112
commit 2d2c5fc06e
+27 -27
View File
@@ -52,7 +52,7 @@
//check to see if the process is running //check to see if the process is running
if (file_exists($file)) { if (file_exists($file)) {
$pid = file_get_contents($file); $pid = file_get_contents($file);
if (posix_getsid($pid) === false) { if (posix_getsid($pid) === false) {
//process is not running //process is not running
$exists = false; $exists = false;
} }
@@ -191,34 +191,34 @@
$database = new database; $database = new database;
$email_queue_attachments = $database->select($sql, $parameters, 'all'); $email_queue_attachments = $database->select($sql, $parameters, 'all');
if (is_array($email_queue_attachments) && @sizeof($email_queue_attachments) != 0) { if (is_array($email_queue_attachments) && @sizeof($email_queue_attachments) != 0) {
foreach($email_queue_attachments as $field) { foreach($email_queue_attachments as $i => $field) {
$email_queue_attachment_uuid = $field['email_queue_attachment_uuid']; $email_queue_attachment_uuid = $field['email_queue_attachment_uuid'];
$domain_uuid = $field['domain_uuid']; $domain_uuid = $field['domain_uuid'];
$email_attachment_type = $field['email_attachment_type']; $email_attachment_type = $field['email_attachment_type'];
$email_attachment_path = $field['email_attachment_path']; $email_attachment_path = $field['email_attachment_path'];
$email_attachment_name = $field['email_attachment_name']; $email_attachment_name = $field['email_attachment_name'];
//$email_attachment_base64= $field['email_attachment_base64']; $email_attachment_mime_type = $field['email_attachment_mime_type'];
switch ($email_attachment_type) { if (!$email_attachment_mime_type) {
case "wav": switch ($email_attachment_type) {
$mime_type = "audio/x-wav"; case "wav":
break; $email_attachment_mime_type = "audio/x-wav";
case "mp3": break;
$mime_type = "audio/x-mp3"; case "mp3":
break; $email_attachment_mime_type = "audio/x-mp3";
case "pdf": break;
$mime_type = "application/pdf"; case "pdf":
break; $email_attachment_mime_type = "application/pdf";
case "tif": break;
$mime_type = "image/tiff"; case "tif":
break; case "tiff":
case "tiff": $email_attachment_mime_type = "image/tiff";
$mime_type = "image/tiff"; break;
break; default:
default: $email_attachment_mime_type = "binary/octet-stream";
$mime_type = "binary/octet-stream"; break;
break; }
} }
if (isset($voicemail_transcription_enabled) && $voicemail_transcription_enabled == 'true') { if (isset($voicemail_transcription_enabled) && $voicemail_transcription_enabled == 'true') {
@@ -235,8 +235,6 @@
//echo "email_body before: ".$email_body."\n"; //echo "email_body before: ".$email_body."\n";
$email_body = str_replace('${message_text}', $transcribe_message, $email_body); $email_body = str_replace('${message_text}', $transcribe_message, $email_body);
//echo "email_body after: ".$email_body."\n";
//unset($field);
} }
else { else {
$email_body = str_replace('${message_text}', '', $email_body); $email_body = str_replace('${message_text}', '', $email_body);
@@ -255,9 +253,11 @@
//$email_attachments[0]['value'] = base64_encode(file_get_contents($email_attachment_path.'/'.$email_attachment_name)); //$email_attachments[0]['value'] = base64_encode(file_get_contents($email_attachment_path.'/'.$email_attachment_name));
//add email attachment as a file for the send_email function //add email attachment as a file for the send_email function
$email_attachments[0]['type'] = 'file'; $email_attachments[$i]['cid'] = $field['email_attachment_cid'];
$email_attachments[0]['name'] = $email_attachment_name; $email_attachments[$i]['mime_type'] = $email_attachment_mime_type;
$email_attachments[0]['value'] = $email_attachment_path.'/'.$email_attachment_name; $email_attachments[$i]['name'] = $email_attachment_name;
$email_attachments[$i]['path'] = $email_attachment_path;
$email_attachments[$i]['base64'] = $field['email_attachment_base64'];
} }
} }
unset($parameters); unset($parameters);