diff --git a/app/Mail/Engine/InvoiceEmailEngine.php b/app/Mail/Engine/InvoiceEmailEngine.php index fa88fa67a815..69810ba626ca 100644 --- a/app/Mail/Engine/InvoiceEmailEngine.php +++ b/app/Mail/Engine/InvoiceEmailEngine.php @@ -143,11 +143,11 @@ class InvoiceEmailEngine extends BaseEmailEngine // Storage::url foreach ($this->invoice->documents as $document) { - $this->setAttachments([['path' => $document->filePath(), 'name' => $document->name, 'mime' => NULL, 'file' => base64_encode($document->getFile())]]); + $this->setAttachments([['path' => $document->filePath(), 'name' => $document->name, 'mime' => NULL, ]]); } foreach ($this->invoice->company->documents as $document) { - $this->setAttachments([['path' => $document->filePath(), 'name' => $document->name, 'mime' => NULL, 'file' => base64_encode($document->getFile())]]); + $this->setAttachments([['path' => $document->filePath(), 'name' => $document->name, 'mime' => NULL, ]]); } $line_items = $this->invoice->line_items; @@ -165,7 +165,7 @@ class InvoiceEmailEngine extends BaseEmailEngine ->cursor() ->each(function ($expense) { foreach ($expense->documents as $document) { - $this->setAttachments([['path' => $document->filePath(), 'name' => $document->name, 'mime' => NULL, 'file' => base64_encode($document->getFile())]]); + $this->setAttachments([['path' => $document->filePath(), 'name' => $document->name, 'mime' => NULL, ]]); } }); } @@ -181,7 +181,7 @@ class InvoiceEmailEngine extends BaseEmailEngine ->cursor() ->each(function ($task) { foreach ($task->documents as $document) { - $this->setAttachments([['path' => $document->filePath(), 'name' => $document->name, 'mime' => NULL, 'file' => base64_encode($document->getFile())]]); + $this->setAttachments([['path' => $document->filePath(), 'name' => $document->name, 'mime' => NULL, ]]); } }); } diff --git a/app/Mail/Engine/PurchaseOrderEmailEngine.php b/app/Mail/Engine/PurchaseOrderEmailEngine.php index ce4a411b4840..f11e046b68e2 100644 --- a/app/Mail/Engine/PurchaseOrderEmailEngine.php +++ b/app/Mail/Engine/PurchaseOrderEmailEngine.php @@ -143,13 +143,13 @@ class PurchaseOrderEmailEngine extends BaseEmailEngine // Storage::url foreach ($this->purchase_order->documents as $document) { - // $this->setAttachments([['path' => $document->filePath(), 'name' => $document->name, 'mime' => null]]); - $this->setAttachments([['path' => $document->filePath(), 'name' => $document->name, 'mime' => NULL, 'file' => base64_encode($document->getFile())]]); + $this->setAttachments([['path' => $document->filePath(), 'name' => $document->name, 'mime' => null]]); + // $this->setAttachments([['path' => $document->filePath(), 'name' => $document->name, 'mime' => NULL, 'file' => base64_encode($document->getFile())]]); } foreach ($this->purchase_order->company->documents as $document) { - // $this->setAttachments([['path' => $document->filePath(), 'name' => $document->name, 'mime' => null]]); - $this->setAttachments([['path' => $document->filePath(), 'name' => $document->name, 'mime' => NULL, 'file' => base64_encode($document->getFile())]]); + $this->setAttachments([['path' => $document->filePath(), 'name' => $document->name, 'mime' => null]]); + // $this->setAttachments([['path' => $document->filePath(), 'name' => $document->name, 'mime' => NULL, 'file' => base64_encode($document->getFile())]]); } } diff --git a/app/Mail/Engine/QuoteEmailEngine.php b/app/Mail/Engine/QuoteEmailEngine.php index 5b1387ed6980..63271c0600ba 100644 --- a/app/Mail/Engine/QuoteEmailEngine.php +++ b/app/Mail/Engine/QuoteEmailEngine.php @@ -123,7 +123,7 @@ class QuoteEmailEngine extends BaseEmailEngine // $this->setAttachments([$this->quote->pdf_file_path($this->invitation)]); // } - $pdf = ((new CreateRawPdf($this->invitation, $this->invitation->company->db))->handle()); + $pdf = ((new CreateRawPdf($this->invitation, $this->invitation->company->db))->handle()); $this->setAttachments([['file' => base64_encode($pdf), 'name' => $this->quote->numberFormatter().'.pdf']]); } @@ -133,11 +133,11 @@ class QuoteEmailEngine extends BaseEmailEngine // Storage::url foreach ($this->quote->documents as $document) { - $this->setAttachments([['path' => $document->filePath(), 'name' => $document->name, 'mime' => NULL, 'file' => base64_encode($document->getFile())]]); + $this->setAttachments([['path' => $document->filePath(), 'name' => $document->name, 'mime' => NULL, ]]); } foreach ($this->quote->company->documents as $document) { - $this->setAttachments([['path' => $document->filePath(), 'name' => $document->name, 'mime' => NULL, 'file' => base64_encode($document->getFile())]]); + $this->setAttachments([['path' => $document->filePath(), 'name' => $document->name, 'mime' => NULL, ]]); } } diff --git a/app/Mail/TemplateEmail.php b/app/Mail/TemplateEmail.php index eb8bdaaed718..b5b443657f78 100644 --- a/app/Mail/TemplateEmail.php +++ b/app/Mail/TemplateEmail.php @@ -162,8 +162,11 @@ class TemplateEmail extends Mailable // // $this->attachData($file_data, $file['name']); // $this->attach($file['path'], ['as' => $file['name'], 'mime' => null]); // } - - $this->attachData(base64_decode($file['file']), $file['name']); + if(array_key_exists('file', $file)) + $this->attachData(base64_decode($file['file']), $file['name']); + else + $this->attach($file['path'], ['as' => $file['name'], 'mime' => null]); + } if ($this->invitation && $this->invitation->invoice && $settings->ubl_email_attachment && $this->company->account->hasFeature(Account::FEATURE_PDF_ATTACHMENT)) {