@@ -149,7 +149,15 @@ public function setMail($mail)
149149
150150 // Reply To
151151 if (!empty ($ mail ->options ['reply_to ' ])) {
152- $ this ->AddReplyTo ($ mail ->options ['reply_to ' ]);
152+ try {
153+ $ this ->AddReplyTo ($ mail ->options ['reply_to ' ]);
154+ } catch (\Exception $ e ) {
155+ // Ignora gli errori per indirizzi email non validi e continua
156+ $ logger = logger_osm ();
157+ $ logger ->addRecord (\Monolog \Logger::WARNING , 'Errore durante l \'impostazione del Reply-To: ' .$ e ->getMessage (), [
158+ 'reply_to ' => $ mail ->options ['reply_to ' ],
159+ ]);
160+ }
153161 }
154162
155163 // Oggetto
@@ -244,7 +252,16 @@ public function addUpload($file_id)
244252 {
245253 $ attachment = database ()->fetchOne ('SELECT * FROM zz_files WHERE id = ' .prepare ($ file_id ));
246254
247- $ this ->addAttachment (base_dir ().'/ ' .\Uploads::getDirectory ($ attachment ['id_module ' ], $ attachment ['id_plugin ' ]).'/ ' .$ attachment ['filename ' ], $ attachment ['original ' ]);
255+ try {
256+ $ this ->addAttachment (base_dir ().'/ ' .\Uploads::getDirectory ($ attachment ['id_module ' ], $ attachment ['id_plugin ' ]).'/ ' .$ attachment ['filename ' ], $ attachment ['original ' ]);
257+ } catch (\Exception $ e ) {
258+ // Ignora gli errori per allegati non validi e continua
259+ $ logger = logger_osm ();
260+ $ logger ->addRecord (\Monolog \Logger::WARNING , 'Errore durante l \'aggiunta dell \'allegato: ' .$ e ->getMessage (), [
261+ 'file_id ' => $ file_id ,
262+ 'filename ' => $ attachment ['original ' ] ?? 'unknown ' ,
263+ ]);
264+ }
248265 }
249266
250267 /**
@@ -267,12 +284,22 @@ public function addReceiver($receiver, $type = null)
267284 }
268285
269286 if (!empty ($ email )) {
270- if ($ type == 'cc ' ) {
271- $ this ->AddCC ($ email , $ name );
272- } elseif ($ type == 'bcc ' ) {
273- $ this ->AddBCC ($ email , $ name );
274- } else {
275- $ this ->AddAddress ($ email , $ name );
287+ try {
288+ if ($ type == 'cc ' ) {
289+ $ this ->AddCC ($ email , $ name );
290+ } elseif ($ type == 'bcc ' ) {
291+ $ this ->AddBCC ($ email , $ name );
292+ } else {
293+ $ this ->AddAddress ($ email , $ name );
294+ }
295+ } catch (\Exception $ e ) {
296+ // Ignora gli errori per indirizzi email non validi e continua con gli altri
297+ // L'eccezione viene registrata ma non interrompe l'elaborazione
298+ $ logger = logger_osm ();
299+ $ logger ->addRecord (\Monolog \Logger::WARNING , 'Errore durante l \'aggiunta del destinatario: ' .$ e ->getMessage (), [
300+ 'email ' => $ email ,
301+ 'type ' => $ type ,
302+ ]);
276303 }
277304 }
278305 }
0 commit comments