Duplicate emails sent (4 emails instead of 1)

Hi all and thanks in advance for help.
I have invoice ninja v5.5.70-W107 self hosted.

Everything is running fine except emails notification. 4 emails are sent out instead of 1 email.
This is recurring problem both with manual send and with automatic send (reminder).

The smtp is external and it register four different emails sent out with one minute difference.
When I send manually, I immediately receive confirmation email is sent.

Any Idea?


@david do you have any ideas?

Some more details. Nothing in lavarel log neither after debug enabled.


Activity log register email sending (user sent email …) at minute 0. At minute 4 the activity log register “the system didn’t succeed to send invoice”.
Details of the error in system activity: file_put_contents (…root…/storage/framework/cache/data/…) failed to open stream: permission denied.

At this point it looks like a retry on sending email, but the email is sent at minute 0 already.

www-data runs apache while the user with permission on the directory runs php-cgi .
Health check is passed without problems.

At this point I removed cron from www-data and added it to the user running php-cgi and now only one email is sent.
I will wait one more day to test about reminders.


Did we chat on slack about this?

The issue is a permissions issue, the system cannot write to the storage/ directory so the job fails and it continues to retry until it hits the limit for emails (4).

Two things to ensure:

  1. Your cron is running as the web user that has permissions to write to storage/ and public/storage
  2. At the very least your storage and public/storage directories must be writable by the webuser.

Hi @david ,
thanks for your reply.
We did not chat on slack but always nice to have some talk anywhere :slight_smile:

Thanks for confirming it. After changed permission as anticipated in the previous post (passed from www-data to the user that exec php-cgi), I get only one single email.

On a user side this is not understanding becase:
The health check will be passed anyway;
You will get the “email sent” message immediately when the mail goes in queue so you don’t check for errors.
Actually you will have to wait for the call of the person that receive 4 invoice and reminder to know about the problem.

Do you think it could be possible to fix the health check and/or change the workflow for sending email (if I cannot write the file, then I will not send email and give back error to user)?

Many thanks