From 5f3efdc5ffeee949d284b98b478c7ce9f768bb3b Mon Sep 17 00:00:00 2001 From: David Bomba Date: Thu, 11 Feb 2021 16:48:13 +1100 Subject: [PATCH 1/2] Working on swift attachments --- app/Helpers/Mail/GmailTransport.php | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/app/Helpers/Mail/GmailTransport.php b/app/Helpers/Mail/GmailTransport.php index 9473f6c106a8..937ddb2ba7fe 100644 --- a/app/Helpers/Mail/GmailTransport.php +++ b/app/Helpers/Mail/GmailTransport.php @@ -65,10 +65,18 @@ class GmailTransport extends Transport nlog("trying to attach"); nlog($child->getContentType()); +// $attachment = (new Swift_Attachment()) +// ->setFilename('my-file.pdf') +// ->setContentType('application/pdf') +// ->setBody($data) +// ; + if($child->getContentType() != 'text/plain'){ - $this->gmail->attach(TempFile::filePath($child)); + nlog($child->getHeaders()); + $this->gmail->attach(TempFile::filePath($child)); + } From 64351e0f0aeba21c568d64076334f55343a1f75f Mon Sep 17 00:00:00 2001 From: = Date: Thu, 11 Feb 2021 18:32:49 +1100 Subject: [PATCH 2/2] Fixes for attachments with gmail --- app/Helpers/Mail/GmailTransport.php | 25 ++++++++++++++++++++----- 1 file changed, 20 insertions(+), 5 deletions(-) diff --git a/app/Helpers/Mail/GmailTransport.php b/app/Helpers/Mail/GmailTransport.php index 937ddb2ba7fe..64770de41e8c 100644 --- a/app/Helpers/Mail/GmailTransport.php +++ b/app/Helpers/Mail/GmailTransport.php @@ -65,11 +65,6 @@ class GmailTransport extends Transport nlog("trying to attach"); nlog($child->getContentType()); -// $attachment = (new Swift_Attachment()) -// ->setFilename('my-file.pdf') -// ->setContentType('application/pdf') -// ->setBody($data) -// ; if($child->getContentType() != 'text/plain'){ @@ -80,6 +75,26 @@ class GmailTransport extends Transport } + foreach ($message->getChildren() as $child) { + nlog("trying to attach"); + + if($child->getContentType() != 'text/plain'){ + +// $attachment = (new Swift_Attachment()) +// ->setFilename($child->getHeaders()->get('Content-Type')->getParameter('name')) +// ->setContentType($child->getContentType()) +// ->setBody($child->getBody()); + + $this->gmail->attach(new Swift_Attachment($child)); + + } + + + } //todo this should 'just work' + + + + } //todo this should 'just work' $this->gmail->send();