Cloudways - Email problems and errors

Hello,

I started testing out version 4 a few weeks ago on a shared hosting platform. I have since moved to Cloudways, which unfortunately only allows one php version for the whole server, rather than per application. As I have other applications using php7.4, I decided to go with version 5.

I’ve installed and reinstalled v5 a few times while testing it, usually due to it having problems after fiddling with it and doing a clean install to get it working again.

I’m self hosting on Cloudways and have version 5.1.31 installed. I have two companies set up, which are services I offer with different branding.

Some issues I’ve found so far while testing.

  1. I have some issues regarding mailing invoices. First issue is, they’re only sent after running ‘php artisan queue:work’, even though I’ve changed the .env setting to QUEUE_CONNECTION = database, nothing happens until the command is run. Once I run the queue command via ssh, the only way out of it is to use Ctrl Z, which stops it running. Should it, and can it, be left running? Is there a better way for it to run in the first place?
    The cronjob for sending invoices and reminders is set to 5 minutes and I followed the Cloudways guide and looks like this:
    */5 * * * * cd /home/master/applications/userfolder/public_html/ && php /home/master/applications/userfolder/public_html/artisan ninja:send-invoices #CloudwaysApps
    It has the follwoing error in the laravel logs:
    production.ERROR: Method App\Console\Commands\SendRemindersCron::webHookExpiredQuotes does not exist. {“exception”:"[object] (BadMethodCallException(code: 0):

  2. I can’t see separate SMTP settings for each company, like there was in version 4, I only see company specific ‘reply to’ settings. This means the emails can only come from one address via one SMTP setup for all companies rather than using separate SMTP setups and email addresses for each company. This doesn’t seem right, or am I missing something?

  3. My invoice and quote emails keep arriving in spam even though I have corrected my spf settings, and checked them via an email testing site. Maybe this is related to point 2 where I have a different ‘from’ email address to the ‘reply to’ address?

  4. If I check the Delivery Note option I get a server 500 error and I can’t see the pdf, when I untick it the pdf reappears.

  5. Oddly, even though the email is working, if I run ‘php artisan ninja:send-test-emails’ I get the following error:

ErrorException

Trying to get property ‘type_id’ of non-object

at app/Services/PdfMaker/Design.php:254
250▕ */
251▕ public function productTable(): array
252▕ {
253▕ $product_items = collect($this->entity->line_items)->filter(function ($item) {
➜ 254▕ return $item->type_id == 1;
255▕ });
256▕
257▕ if (count($product_items) == 0) {
258▕ return [];

1 app/Services/PdfMaker/Design.php:254
Illuminate\Foundation\Bootstrap\HandleExceptions::handleError()

2 [internal]:0
App\Services\PdfMaker\Design::App\Services\PdfMaker{closure}()

  1. If I run ‘php artisan test’ the following fail comes up:
    FAIL Tests\Integration\DownloadHistoricalInvoiceTest
    ✓ activity accessible
    ✓ backup exists
    ⨯ backup download

Expected status code 200 but received 500.
Failed asserting that 200 is identical to 500.

at vendor/phpunit/phpunit/phpunit:61
57▕ unset($options);
58▕
59▕ require PHPUNIT_COMPOSER_INSTALL;
60▕
➜ 61▕ PHPUnit\TextUI\Command::main();
62▕

  1. Running ‘php artisan ninja:check-data’ - results in the following “x invoices records with incorrect client company id” message coming up. If I try and add anything to the ID field of the company, I now get the following line “x activities records with incorrect client company id” as well.

So, I know I have written a lot but any pointers would be greatly appreciated here, thanks.

For #3 I suggest sending a test invoice to https://www.mail-tester.com

@david, do you have any thoughts about the other issues?

Hi Hillel,
Okay, thanks for responding so quickly.
I haven’t done the email tester with an invoice yet as I wanted to make sure the emails were being sent properly first. I’ll try it now anyway and see what happens.
Keep up the good work.

1 Like

@SCGCarto

Hi Stuart,

It looks like there are multiple issues. v5 is completely different to v5, so the entire setup process and configuration is different. It looks like you have merged some v4 settings in v5 which is incompatible.

There can only be one SMTP configuration per installation. We have never supported more than one.

I suggest changing your QUEUE_CONNECTION from database to sync this will fire your emails instantly.

Also the cron setup is different in v5, please see here for more information

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

It also appears that your PDFs are not generating correctly. you’ll want to read the docs for specifics on how to debug this depending on your platform.

Hi David,

Thanks for responding. I’ve been really busy so haven’t had a chance to reply until now.

Most of what I have been doing are shots in the dark because I’m not sure what things from the Linux guides are relevant, or not relevant, to Cloudways.

I’m not sure what you mean by v4 settings “being merged” as this is a completely fresh install, and no migration from version 4 has taken place at all.

With the SMTP settings, I’m only going on what I was able to do in version 4 and looking at the v4 .env file from my shared hosting backup. Version 4 was installed on a shared host via their installer system and I didn’t know there was an .env file until I started installing version 5 on Cloudways. The v4 .env file from my backup has 3 blocks of SMTP settings, the first one is blank, while the other two are for each company. I know they worked because I successfully sent emails through each of them while running it. I have not tried to do this on v5 btw.

I’ll change the queue connection setting and see what happens.

I didn’t even know how to setup the Cronjob with Cloudways initially. The format of the cronjob instruction in my original message is the structure that Cloudways has in it’s documentation, and I checked it via Cloudways’ own Cron Job Management under its Application Management section, and that was the only structure that worked. Oddly enough, the cronjob worked on my previous testing go around just before this latest clean install, with the only difference being the IN version was slightly older. I have added the schedule:run command from the instructions, the red cron error triangle has gone away but the laravel log error is still present.

I setup PhantomJSCloud with an API key for my PDFs and can view, customise and email the PDFs without any issue. When I tick that delivery note option or click on the Download button within the client portal the error occurs. I noticed the troubleshooting says I can try turning off PhantomJS and use NINJA_HOSTED_PDF=true, which I have tried, and the delivery note tick box gave a 400 error instead. So. I changed it back.
In the .env file, do I need the quotes around the keys and passwords, and what is the PhantomJS secret bit all about and when/where should it be used?

Thanks.