Fix the email attachments that are being sent through the email queue.

This commit is contained in:
FusionPBX 2022-04-19 00:48:04 -06:00 committed by GitHub
parent 4f5b832157
commit c6a36cdf45
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 15 additions and 24 deletions

View File

@ -60,9 +60,9 @@ if (!class_exists('email')) {
//assign the variables //assign the variables
$this->app_name = 'email'; $this->app_name = 'email';
$this->name = 'email'; $this->name = 'email';
//$this->app_uuid = 'zzz'; $this->app_uuid = '7a4fef67-5bf8-436a-ae25-7e3c03afcf96';
$this->priority = 3; $this->priority = 0;
$this->debug_level = 0; $this->debug_level = 3;
$this->read_confirmation = false; $this->read_confirmation = false;
} }
@ -257,20 +257,21 @@ if (!class_exists('email')) {
$y = 0; $y = 0;
foreach ($this->attachments as $attachment) { foreach ($this->attachments as $attachment) {
//set the name of the file //set the name of the file
$attachment['name'] = $attachment['name'] != '' ? $attachment['name'] : basename($attachment['value']); if (strlen($attachment['value']) < 255 && file_exists($attachment['value'])) {
$attachment['name'] = $attachment['name'] != '' ? $attachment['name'] : basename($attachment['value']);
$attachment['type'] = strtolower(pathinfo($attachment['value'], PATHINFO_EXTENSION));
}
//add the attachments to the array //add the attachments to the array
$array['email_queue_attachments'][$y]['email_queue_attachment_uuid'] = uuid(); $array['email_queue_attachments'][$y]['email_queue_attachment_uuid'] = uuid();
$array['email_queue_attachments'][$y]['email_queue_uuid'] = $email_queue_uuid; $array['email_queue_attachments'][$y]['email_queue_uuid'] = $email_queue_uuid;
$array['email_queue_attachments'][$y]['domain_uuid'] = $_SESSION['domain_uuid']; $array['email_queue_attachments'][$y]['domain_uuid'] = $_SESSION['domain_uuid'];
$array['email_queue_attachments'][$y]['email_attachment_type'] = $email_attachment_type; $array['email_queue_attachments'][$y]['email_attachment_type'] = $attachment['type'];
$array['email_queue_attachments'][$y]['email_attachment_path'] = $email_attachment_path; $array['email_queue_attachments'][$y]['email_attachment_name'] = $attachment['name'];
$array['email_queue_attachments'][$y]['email_attachment_name'] = $email_attachment_name; if (strlen($attachment['value']) < 255 && file_exists($attachment['value'])) {
$array['email_queue_attachments'][$y]['email_attachment_path'] = pathinfo($attachment['value'], PATHINFO_DIRNAME);
if ($attachment['type'] == 'file' || $attachment['type'] == 'path') {
$array['email_queue_attachments'][$y]['email_attachment_path'] = $attachment['value'];
} }
else if ($attachment['type'] == 'string') { else {
$array['email_queue_attachments'][$y]['email_attachment_base64'] = base64_decode($attachment['value']); $array['email_queue_attachments'][$y]['email_attachment_base64'] = base64_decode($attachment['value']);
} }
$y++; $y++;
@ -467,16 +468,6 @@ if (!class_exists('email')) {
if (is_array($this->attachments) && sizeof($this->attachments) > 0) { if (is_array($this->attachments) && sizeof($this->attachments) > 0) {
foreach ($this->attachments as $attachment) { foreach ($this->attachments as $attachment) {
//set the type if not set
if (!isset($attachment['type'])) {
if (strlen($attachment['value']) < 255 && file_exists($attachment['value'])) {
$attachment['type'] = 'file';
}
else {
$attachment['type'] = 'string';
}
}
//set the name of the file //set the name of the file
$attachment['name'] = $attachment['name'] != '' ? $attachment['name'] : basename($attachment['value']); $attachment['name'] = $attachment['name'] != '' ? $attachment['name'] : basename($attachment['value']);
@ -494,7 +485,7 @@ if (!class_exists('email')) {
case ".wav": case ".wav":
$attachment['mime_type'] = 'audio/x-wav'; $attachment['mime_type'] = 'audio/x-wav';
break; break;
case ".opus": case "opus":
$attachment['mime_type'] = 'audio/opus'; $attachment['mime_type'] = 'audio/opus';
break; break;
case ".ogg": case ".ogg":
@ -503,10 +494,10 @@ if (!class_exists('email')) {
} }
//add the attachments //add the attachments
if ($attachment['type'] == 'file' || $attachment['type'] == 'path') { if (strlen($attachment['value']) < 255 && file_exists($attachment['value'])) {
$mail->AddAttachment($attachment['value'], $attachment['name'], 'base64', $attachment['mime_type']); $mail->AddAttachment($attachment['value'], $attachment['name'], 'base64', $attachment['mime_type']);
} }
else if ($attachment['type'] == 'string') { else {
if (base64_encode(base64_decode($attachment['value'], true)) === $attachment['value']) { if (base64_encode(base64_decode($attachment['value'], true)) === $attachment['value']) {
$mail->AddStringAttachment(base64_decode($attachment['value']), $attachment['name'], 'base64', $attachment['mime_type']); $mail->AddStringAttachment(base64_decode($attachment['value']), $attachment['name'], 'base64', $attachment['mime_type']);
} }