diff --git a/CHANGELOG.md b/CHANGELOG.md index 4be2186..724886c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,11 @@ +# v3.0.1 +## 04/15/2019 + +1. [](#improved) + * Put a `try/catch` around email attachments and log any errors rather than hard fail +1. [](#bugfix) + * Fixed missing attachments when sending an email using a form [form#333](https://github.com/getgrav/grav-plugin-form/issues/333) + # v3.0.0 ## 04/11/2019 diff --git a/blueprints.yaml b/blueprints.yaml index b3b8084..50a7a53 100644 --- a/blueprints.yaml +++ b/blueprints.yaml @@ -1,5 +1,5 @@ name: Email -version: 3.0.0 +version: 3.0.1 testing: false description: Enables the emailing system for Grav icon: envelope diff --git a/email.php b/email.php index b14545e..6ac1062 100644 --- a/email.php +++ b/email.php @@ -71,6 +71,10 @@ public function onFormProcessed(Event $event) 'form' => $form ); + // Copy files now, we need those. + // TODO: we need a better solution. Maybe we can use streams for the attachments? + $form->copyFiles(); + $grav = Grav::instance(); $grav->fireEvent('onEmailSend', new Event(['params' => &$params, 'vars' => &$vars])); @@ -89,7 +93,12 @@ public function onFormProcessed(Event $event) $filename = ROOT_DIR . $fileValues['path']; } - $message->attach(\Swift_Attachment::fromPath($filename)); + try { + $message->attach(\Swift_Attachment::fromPath($filename)); + } catch (\Exception $e) { + // Log any issues + $grav['log']->error($e->getMessage()); + } } } }