V5 Cronjob Exclamation Mark + Emails not being sent

I have just installed v5 and migrated from v4.

I have configured SMTP the same as per my V4 .env (and it works in v4).

Emails are not being sent in V5. They are queued to be sent but are never received.

There is a red exclamation mark in the bottom left telling me I need to enable cronjobs. I thought it was already working because migration completed but since emails are not being sent, I’m not sure that the cron job is working now.

Why would this be?

I have tried refreshing data under Device Settings > Refresh data.
I have checked www-data is the owner for my invoiceninja directory.
I have checked laravel.log and there are no errors.
I have checked sudo grep CRON /var/log/syslog and there are no errors.

I also tried supervisor and that made no difference. I also tried changing QUEUE_CONNECTION types whenever I tried each of these changes.

I attached my crontab and an image of the error message.

Just can’t get emails to send out over SMTP and that exclamation is still there so I assume this must be a crontab issue. Crontab was set up under: sudo -u www-data crontab -e

Thanks.

crons

Hi,

Have you seen the info here?

https://invoiceninja.github.io/docs/self-host-troubleshooting/

Maybe you didn’t run php artisan optimize after making the change?

Thanks, yes I checked that info a thousand times and tried all varieties of changes.

Ran artisan optimise each time, cleared cache and refreshed from the dashboard. Nothing works.

@david do you have any ideas?

Without changing anything, the exclamation mark disappeared after several hours. I went to sleep, woke up and now its gone.

I found this thread, which details that the cron check related to the exclamation mark was only being checked every 24 hours: v5 - Cron, jobs setup issues · Issue #3916 · invoiceninja/invoiceninja · GitHub

That seems to have been reduced, but my feedback is to make this check a LOT more frequent as it drove me nuts thinking there was an issue, when in fact, there wasn’t. Not with cron anyway. Seems it was a false positive.

I also managed to get my emails working. The issue was that double quotes were missing as per here: Free Source Available Invoicing, Expenses & Time-Tracking | Invoice Ninja

I must of missed that. It’s also worth noting that in v4, I didn’t require these double quotes, but for anyone with these issues, you ABSOLUTELY need the double quotes when configuring SMTP.

So, in summary:

  • The Cron check in InvoiceNinja V5 only occurs every several hours so even if cron has been since setup correctly, you need to wait for the next time it checks for the exclamation to go away. This is why my migration worked as I performed the V5 setup. v5 repeatedly was showing the exclamation indicating error when infact cron was working properly. I strongly recommend improving the cron check error as this false positive caused me a huge headache thinking something wasn’t working and it will definitely confuse others. I just tested again with a fresh setup with cron configured first and the exclamation remains. The check should be run at first login at least. Using /update?secret=‘secret here’ in the address bar resolves this issue immediately if cron has already been configured correctly and the exclamation mark goes away.

  • If configuring SMTP, the double quotes are essential in your .evn for V5 (whereas for some reason they weren’t in v4). See the email troubleshooting info here: Free Source Available Invoicing, Expenses & Time-Tracking | Invoice Ninja. It’s also worth noting that on the setup screen for V5, I couldn’t progress without choosing log as I received an error. I had to choose log, then proceed to configure SMTP manually via the .env file. Additionally, the setup page did fill in some of the information to the .env file I had entered on the setup page but it did not put the double quotes.

  • cd into your invoiceninja root directory and run ‘sudo php artisan optimize’ every time the .env is changed. This is somewhat documented but should be made very clear. Changes don’t seem to “update” otherwise.

  • As some side feedback, I also recommend making snappdf the default because initially I had more PhantomJS issues and well, screw PhantomJS.

Thanks for your help, continued hard work on Invoice Ninja and I hope this feedback can be taken on board to improve V5 and the documentation :slight_smile:

Github issue created here: V5 Fresh install, Invoiceninja does not initially check cron configuration "The crons need to be enabled" · Issue #6544 · invoiceninja/invoiceninja · GitHub

1 Like

Thanks for the details!

cc @david