terminal42 / contao-notification_center

The most popular notification configuration extension for the Contao Open Source CMS!
63 stars 38 forks source link

Could not send email to <...> Unable to open path to message files #338

Open megmed opened 3 months ago

megmed commented 3 months ago

Sometimes I get the following error in the message queue list of the notification center: Fehler beim Senden der Nachricht. Prüfen Sie das System-Log für Details.

In the contao system log the following ist stated: Could not send email to "mail@test.de" for message ID 11: Unable to open path "test/contao4/var/notification_center/1312/Attachment.pdf"

I assume that this happens when the message queue tries to resend an email that could not be sent on the first attempt. I had a quick look in the source code and it seems that the message files are deleted no matter the email could be sent successfully or not.
https://github.com/terminal42/contao-notification_center/blob/bd6f6e48e3a5626e615b25eeba5cdcc82dcc2ae7/library/NotificationCenter/Queue/QueueManager.php#L100-L110 I guess $this->removeMessageFiles($msg->id); should only be called if the email was sent successfully? Like this:

if (!$result) { 
         $msg->error = 1; 
     } else { 
         $msg->dateSent = time(); 
         // Remove the temporary message files 
         $this->removeMessageFiles($msg->id);
     } 

After that, adding the message to the queue again using the button from the queue list should also work, which is currently not the case for messages with file attachments. image