Cron Jobs and email issue

I managed to setup IN on my domain and finally made it passed the login window. The problem I have now seems to be a recurrent issue in this forum although I haven’t been able to transpose the posted solutions to my situation.

  • I’m unable to add users because no confirmation emails are being sent out (although each time I get a message saying that an message was sent to the given email address).

  • I get a warning symbol (bottom of nav) telling me cron jobs must be enabled.

In cPanel I tried a few edits to the cron job, as suggested. I looked for logged errors that could be related but my knowledge of cron things is limited and I’m also not totally php-fluent.

What I did find that could maybe help resolve the issue is an entry in the Apache error log stating that the file /home/usr/public_html/index.php does not exist.
That file (in my case) is located at /home/usr/public_html/subdomain/public/index.php. But I don’t know where this can be corrected.
Yet the page loads correctly when I enter the address of the IN subdomain in my browser.


Meanwhile, is there an alternative way to create users that doesn’t require sending out emails? Let’s say I can’t resolve this issue pronto, I could at least for now proceed further and get familiar with other aspects of the platform.

Hi,

What do you see when running the cron command from the CLI without >> /dev/null 2>&1 at the end?

What is the queue setting set to in the .env file?

As for queue settings, does this cover it?

BROADCAST_DRIVER=log
LOG_CHANNEL=stack
CACHE_DRIVER=file
QUEUE_CONNECTION=sync
SESSION_DRIVER=file
SESSION_LIFETIME=120

…or should I paste the entire .env file?

Now for the cron command, my procedure was:

  1. Edit the command in cPanel Cron Jobs;
  2. Log into IN again and monitor for changes in behaviour.

Nothing to report. No email being sent and cron job warning still showing.

I’m not sure what you mean by CLI. Command LIne? CLIent?

I’m also not sure where to look for results. I find entries in the Apache Error log but is there somewhere else I should be looking for event records? Some posts on this forum mention something about a “lavarel.log” but it doesn’t look like there is anything “lavarel” in my setup.

@david do you have any suggestions?

You’ll want to get the applicatino working with:

QUEUE_CONNECTION=sync

After making this change, you’ll want to update the cache either by running at the command line

sudo -u www-data php artisan optimize

Or by visiting this URL where you have configured Invoice Ninja

https://url/update?secret=

Then reattempt to send the email.

If the email does not send, it means there is a configuration with your email server, You’ll want to inspect the logs in storage/logs/laravel.log and/or check the activities/system logs tab on the dashboard.

QUEUE_CONNECTION=sync: where should this go? in the .env file?
It’s already there! (see above).

Should I proceed to step 2 anyway?

@Benoit,

Just to be doubly sure about the .env file, can you ensure there isn’t another row in there with

QUEUE_CONNECTION=database

I debugged a similiar issue today and there were two entries which was the reason why the system was not using sync.

After you’ve confirmed only one QUEUE_CONNECTION and it is set to sync, please run the second command and then retry the resend invite.

No other instance of QUEUE_CONNECTION in the .env file.
Here’s the full content (minus bits I thought could be compromising)…

APP_NAME=“Invoice Ninja”
APP_ENV=production
APP_KEY=appkeycode
APP_DEBUG=“false”

APP_URL=“https://mydomain.com/subdomain/public”

DB_CONNECTION=“mysql”
MULTI_DB_ENABLED=false

DB_HOST=“localhost”
DB_DATABASE=“something_ninjNNN”
DB_USERNAME=“something_ninjNNN
DB_PASSWORD=“dbpwcode
DB_PORT=“9999

DEMO_MODE=false

BROADCAST_DRIVER=log
LOG_CHANNEL=stack
CACHE_DRIVER=file
QUEUE_CONNECTION=sync
SESSION_DRIVER=file
SESSION_LIFETIME=120

REDIS_HOST=127.0.0.1
REDIS_PASSWORD=null
REDIS_PORT=8888

MAIL_MAILER=“smtp”
MAIL_HOST=“mail.mydomain.com
MAIL_PORT=“465”
MAIL_USERNAME=“admin@mydomain.com
MAIL_PASSWORD=“*******”
MAIL_ENCRYPTION=“ssl”
MAIL_FROM_ADDRESS=“admin@mydomain.com
MAIL_FROM_NAME=“System”

POSTMARK_API_TOKEN=
REQUIRE_HTTPS=“true”

GOOGLE_MAPS_API_KEY=
ERROR_EMAIL=
TRUSTED_PROXIES=

NINJA_ENVIRONMENT=“selfhost”

#options - snappdf / phantom / hosted_ninja
PDF_GENERATOR=hosted_ninja

PHANTOMJS_KEY=‘a-demo-key-with-low-quota-per-ip-address’
PHANTOMJS_SECRET=secret

UPDATE_SECRET=somesortofpasswordcode

DELETE_PDF_DAYS=60
DELETE_BACKUP_DAYS=60

COMPOSER_AUTH=‘{“github-oauth”: {“github.com”: “${{ secrets.GITHUB_TOKEN }}”}}’

GOOGLE_PLAY_PACKAGE_NAME=
APPSTORE_PASSWORD=

MICROSOFT_CLIENT_ID=
MICROSOFT_CLIENT_SECRET=
MICROSOFT_REDIRECT_URI=

APPLE_CLIENT_ID=
APPLE_CLIENT_SECRET=
APPLE_REDIRECT_URI=

@Benoit

Just to confirm, did you attempt to resend + check activity/system logs tab for any messages?

If there are not error messages you may need to set

APP_DEBUG=“true”

and then reoptimize.

It’s not clear to me where the activity and/or system logs are to be found. All I could find in cPanel was an Apache error log and with a file browser I found an access log.

Do I need to ask my domain host?

@Benoit

On the dashboard of the application you can find the Activity and System Logs tab

Inside here should be more information if there are email failures.

Your error logs are located in the invoice ninja directory of your webhost under storage/logs/laravel.log

So I created a client (with my own yahoo email address), then emailed this client with an invoice.

Says “email was sent out successfully”

Activity log entries:

 1:01  System Administrator created client XXXX
 1:03  System Administrator created invoice 0001
 1:04  Client XXXX has viewed invoice 0001
 1:05  System Administrator has emailed invoice 0001 to client XXXX

*Note: my setup is in French so my translations may differ from the original phrases.

System Log is a blank page.
storage/logs/ directory is empty (no sign of laravel.log).

I never received any email.

APP_DEBUG=“true”… OK done.

Now “reoptimize” you said… hmmm! Is there a button on the dashboard for that?

I have the same issue! My emails going perfectly to my clients’ couple of days
Then suddenly it stopped working itself!

Is there a support ticket option giving access to our website and solving this issue from your end… pls

It seems I have reached a dead end.

@david Is my cron job right for email function please guide me

cd /home2/mycapanelname/domains/mydomain.com/public_html && /opt/alt/php81/usr/bin/php -d register_argc_argv=On artisan schedule:run >> /dev/null 2>&1

This looks like the correct format.

If you are not seeing any of the cron jobs work, you may want to change the command to pipe its output to a log file so that you can see what the system is returning when it attempts to run.

cd /home2/mycapanelname/domains/mydomain.com/public_html && /opt/alt/php81/usr/bin/php -d register_argc_argv=On artisan schedule:run >> schedule.log

Also just to confirm that you are executing the job every minute with the cron schedule


Yes executing the job very minute

“change the command to pipe its output to a log file so that you can see what the system is returning when it attempts to run”
This I am not aware of it