From 1e5b1122540a1ab8426838e4c8514d2d60966e5f Mon Sep 17 00:00:00 2001 From: David Bomba Date: Thu, 11 Feb 2021 14:06:03 +1100 Subject: [PATCH 1/2] Filter additional exceptions --- app/Exceptions/Handler.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/app/Exceptions/Handler.php b/app/Exceptions/Handler.php index 38007c848d0d..850c67dfaeb1 100644 --- a/app/Exceptions/Handler.php +++ b/app/Exceptions/Handler.php @@ -111,6 +111,10 @@ class Handler extends ExceptionHandler return false; } + if (strpos($exception->getMessage(), 'expects parameter 1 to be resource') !== false) { + return false; + } + return true; } From a36cfb99b841ecfd45c5e10635c56e21b97d329c Mon Sep 17 00:00:00 2001 From: David Bomba Date: Thu, 11 Feb 2021 14:43:48 +1100 Subject: [PATCH 2/2] GMail attachments --- app/Helpers/Mail/GmailTransport.php | 8 ++++++-- app/Utils/TempFile.php | 12 ++++++++++++ 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/app/Helpers/Mail/GmailTransport.php b/app/Helpers/Mail/GmailTransport.php index 81182b44d27d..9473f6c106a8 100644 --- a/app/Helpers/Mail/GmailTransport.php +++ b/app/Helpers/Mail/GmailTransport.php @@ -11,6 +11,7 @@ namespace App\Helpers\Mail; +use App\Utils\TempFile; use Dacastro4\LaravelGmail\Services\Message\Mail; use Illuminate\Mail\Transport\Transport; use Swift_Mime_SimpleMessage; @@ -64,8 +65,11 @@ class GmailTransport extends Transport nlog("trying to attach"); nlog($child->getContentType()); - if($child->getContentType() != 'text/plain') - $this->gmail->attach($child); + if($child->getContentType() != 'text/plain'){ + + $this->gmail->attach(TempFile::filePath($child)); + + } } //todo this should 'just work' diff --git a/app/Utils/TempFile.php b/app/Utils/TempFile.php index 1907e49d10c7..97e71ecf01fc 100644 --- a/app/Utils/TempFile.php +++ b/app/Utils/TempFile.php @@ -20,4 +20,16 @@ class TempFile return $temp_path; } + + /* Downloads a file to temp storage and returns the path - used for mailers */ + public static function filePath($data) :string + { + + $file_path = sys_get_temp_dir().'/'.sha1(microtime()); + + file_put_contents($file_path, $data); + + return $file_path; + + } }