Commit 40c5bb53b5af6b5a04286f0f05fcd60a97f96059

Authored by Etienne Pallier
1 parent f48cb47f
Exists in master and in 2 other branches dev, dev-IRAP

bugfix mail attachements (photo, image)

Showing 1 changed file with 16 additions and 2 deletions   Show diff stats
src/Controller/AppController.php
... ... @@ -1209,7 +1209,14 @@ class AppController extends Controller
1209 1209 if (filter_var($mail, FILTER_VALIDATE_EMAIL)) {
1210 1210 $email = new Email();
1211 1211 $etiquetteFrom = explode("@", $config->sender_mail);
1212   - $email->attachments(["/var/www/html/labinvent/webroot/img/photos/$nomImg"]);
  1212 +
  1213 + // (EP) Je vais tuer le stagiaire qui a fait ça :
  1214 + //$email->attachments(["/var/www/html/labinvent/webroot/img/photos/$nomImg"]);
  1215 + // Il fallait plutot faire ça :
  1216 + $wwwroot_dir = new \Cake\Filesystem\Folder(WWW_ROOT);
  1217 + $absFileName = new \Cake\Filesystem\File($wwwroot_dir->pwd() . DS . 'img' . DS . 'photos' . DS . $nomImg);
  1218 + $email->attachments([$absFileName]);
  1219 +
1213 1220 $email->transport('default')
1214 1221 ->from([
1215 1222 $config->sender_mail => $etiquetteFrom[0]
... ... @@ -1228,7 +1235,14 @@ class AppController extends Controller
1228 1235 if (filter_var($mail, FILTER_VALIDATE_EMAIL)) {
1229 1236 $email = new Email();
1230 1237 $etiquetteFrom = explode("@", $config->sender_mail);
1231   - $email->attachments(["/var/www/html/labinvent/webroot/files/$nomDoc"]);
  1238 +
  1239 + // (EP) Je vais tuer le stagiaire qui a fait ça :
  1240 + //$email->attachments(["/var/www/html/labinvent/webroot/files/$nomDoc"]);
  1241 + // Il fallait plutot faire ça :
  1242 + $wwwroot_dir = new \Cake\Filesystem\Folder(WWW_ROOT);
  1243 + $absFileName = new \Cake\Filesystem\File($wwwroot_dir->pwd() . DS . 'files' . DS . $nomDoc);
  1244 + $email->attachments([$absFileName]);
  1245 +
1232 1246 $email->transport('default')
1233 1247 ->from([
1234 1248 $config->sender_mail => $etiquetteFrom[0]
... ...