From 40c5bb53b5af6b5a04286f0f05fcd60a97f96059 Mon Sep 17 00:00:00 2001 From: Etienne Pallier Date: Fri, 7 Jun 2019 19:42:17 +0200 Subject: [PATCH] bugfix mail attachements (photo, image) --- src/Controller/AppController.php | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/src/Controller/AppController.php b/src/Controller/AppController.php index 8345167..18ebda0 100755 --- a/src/Controller/AppController.php +++ b/src/Controller/AppController.php @@ -1209,7 +1209,14 @@ class AppController extends Controller if (filter_var($mail, FILTER_VALIDATE_EMAIL)) { $email = new Email(); $etiquetteFrom = explode("@", $config->sender_mail); - $email->attachments(["/var/www/html/labinvent/webroot/img/photos/$nomImg"]); + + // (EP) Je vais tuer le stagiaire qui a fait ça : + //$email->attachments(["/var/www/html/labinvent/webroot/img/photos/$nomImg"]); + // Il fallait plutot faire ça : + $wwwroot_dir = new \Cake\Filesystem\Folder(WWW_ROOT); + $absFileName = new \Cake\Filesystem\File($wwwroot_dir->pwd() . DS . 'img' . DS . 'photos' . DS . $nomImg); + $email->attachments([$absFileName]); + $email->transport('default') ->from([ $config->sender_mail => $etiquetteFrom[0] @@ -1228,7 +1235,14 @@ class AppController extends Controller if (filter_var($mail, FILTER_VALIDATE_EMAIL)) { $email = new Email(); $etiquetteFrom = explode("@", $config->sender_mail); - $email->attachments(["/var/www/html/labinvent/webroot/files/$nomDoc"]); + + // (EP) Je vais tuer le stagiaire qui a fait ça : + //$email->attachments(["/var/www/html/labinvent/webroot/files/$nomDoc"]); + // Il fallait plutot faire ça : + $wwwroot_dir = new \Cake\Filesystem\Folder(WWW_ROOT); + $absFileName = new \Cake\Filesystem\File($wwwroot_dir->pwd() . DS . 'files' . DS . $nomDoc); + $email->attachments([$absFileName]); + $email->transport('default') ->from([ $config->sender_mail => $etiquetteFrom[0] -- libgit2 0.21.2