eMails not being send

Hi,

I migrated from 4.5 to v5 yesterday and since then I am trying to get email sending to work. But I can’t get IN to send emails neither through SMTP nor the “standard” way which I suppose is sendmail. Both are available on my server.

Note that I can successfully send a test email from the email smtp settings in IN. But no matter what settings I choose, the .env file never changes.

I can also successfully run this:

php artisan tinker
\Mail::mailer('smtp')->raw('hello world', function($message) {
   $message->subject('Testing email')->to('info@domain.com');
});

I thought maybe the cron job is not running buit even when starting it manually there are no emails being send. I switched to supervisor whose logs look great:

  2024-04-22 14:55:57 App\Services\Email\Email ....................... RUNNING
  2024-04-22 14:56:01 App\Services\Email\Email ................... 3 Sek. DONE
  2024-04-22 14:56:01 App\Listeners\Quote\QuoteEmailActivity ......... RUNNING
  2024-04-22 14:56:01 App\Listeners\Quote\QuoteEmailActivity .... 50.43ms DONE
  2024-04-22 14:56:01 App\Listeners\Quote\QuoteEmailedNotification ... RUNNING
  2024-04-22 14:56:01 App\Listeners\Quote\QuoteEmailedNotification  32.66ms DONE
  2024-04-22 14:57:20 App\Services\Email\Email ....................... RUNNING
  2024-04-22 14:57:23 App\Services\Email\Email ................... 3 Sek. DONE
  2024-04-22 14:57:25 App\Listeners\Quote\QuoteEmailActivity ......... RUNNING
  2024-04-22 14:57:25 App\Listeners\Quote\QuoteEmailedNotification ... RUNNING
  2024-04-22 14:57:25 App\Listeners\Quote\QuoteEmailActivity .... 58.39ms DONE
  2024-04-22 14:57:25 App\Listeners\Quote\QuoteEmailedNotification  63.81ms DONE

Obviously, it’s trying to do some email magic for around 3 seconds - but still there are no mails actually being send.

I am on a fresh selh-hosted IN which shows me my system info as:

PHP:
web: 8.2.18
cli: PHP 8.2.18 (cli) (built: Apr 11 2024 20:37:35) (NTS)
Memory: 128M
API: 5.8.50

here is the relevant part of my .env file:

DB_CONNECTION="mysql"
MULTI_DB_ENABLED=false

DB_HOST="localhost"
DB_DATABASE="ninja"
DB_USERNAME="XXX"
DB_PASSWORD="XXX"
DB_PORT="3306"

DEMO_MODE=false

BROADCAST_DRIVER=log
LOG_CHANNEL=stack
CACHE_DRIVER=file
QUEUE_CONNECTION=database #also didn't work with the original "sync"
SESSION_DRIVER=file
SESSION_LIFETIME=120

REDIS_HOST=127.0.0.1
REDIS_PASSWORD=null
REDIS_PORT=6379

MAIL_MAILER="smtp" #also tried sendmail here
MAIL_HOST="XXX"
MAIL_PORT="587"
MAIL_USERNAME="XXX"
MAIL_PASSWORD="XXX"
MAIL_ENCRYPTION="tls"
MAIL_FROM_ADDRESS="XXX@XXX"
MAIL_FROM_NAME="XXX"
MAIL_VERIFY_PEER=false

Enabling debug mode didn’t yield any additional output, also storage/logs/laravel.log is empty.
After every change I called /update?secret=secret but I can’t say if this has any effect, I simply get redirected to the dashboard without any success message or error.
I also run php artisan optimize.

What else could I try to make email work?

thanks!

Hi,

Have you tried configuring the SMTP credentials in the app on Settings > Email Settings

Hi,

yes I did. And I can successfully send a test email from there.

Is the problem now solved?

No, the problem is still there. IN is not sending any emails.

Are you seeing any specific errors?

Note: you’ll want to keep QUEUE_CONNECTION set to sync until you get it working.

I changed QUEUE_CONNECTION back to sync but still get no emails.

I tried changing MAIL_MAILER to “sendmail” but this doesn’t help.

I tried changing the settings in the app at Settings > Email Settings to SMTP, can successfully send the test email but IN is not sending other mails.

I tried changing the settings in the app at Settings > Email Settings to Standard, there is no test button then and IN doesn’t send any other mails.

What settings is IN using? The settings in Settings > Email Settings or the the settings in the .env file?

I get no specific error, debug mode is on and laravel.log doesn’t show any errors.

The SMTP credentials should be set on Settings > Email Settings, we used the .env file in the past but are moving away from it.

Are there any error in storage/logs or the system_logs table after trying to send an email?

mysql> select * from system_logs;
+----+------------+---------+-----------+-------------+----------+---------+--------------------------------------------------------------------------------------+----------------------------+----------------------------+------------+
| id | company_id | user_id | client_id | category_id | event_id | type_id | log                                                                                  | created_at                 | updated_at                 | deleted_at |
+----+------------+---------+-----------+-------------+----------+---------+--------------------------------------------------------------------------------------+----------------------------+----------------------------+------------+
|  1 |          1 |       1 |      NULL |           5 |       61 |     800 | "New login detected for your account. xxx.xxx.xxx.xxx"                                | 2024-04-22 09:08:45.947144 | 2024-04-22 09:08:45.947144 | NULL       |
|  2 |          1 |       1 |      NULL |           5 |       61 |     800 | "Neue Anmeldung f\u00fcr Ihr Konto erkannt. xxx:xxx:xxx:xxx::1"                    | 2024-04-22 09:20:28.019695 | 2024-04-22 09:20:28.019695 | NULL       |
|  3 |          3 |       1 |      NULL |           5 |       61 |     800 | "Neue Anmeldung f\u00fcr Ihr Konto erkannt. xxx:xxx:xxx:xxx::1" | 2024-04-23 16:48:37.865775 | 2024-04-23 16:48:37.865775 | NULL       |
|  4 |          3 |       1 |      NULL |           5 |       61 |     800 | "Neue Anmeldung f\u00fcr Ihr Konto erkannt. xxx.xxx.xxx.xxx"                          | 2024-04-24 11:01:00.499740 | 2024-04-24 11:01:00.499740 | NULL       |
+----+------------+---------+-----------+-------------+----------+---------+--------------------------------------------------------------------------------------+----------------------------+----------------------------+------------+
4 rows in set (0.00 sec)

and

# ll storage/logs/
total 16
drwxr-xr-x 2 www-data www-data 4096 Apr 22 23:30 ./
drwxr-xr-x 5 www-data www-data 4096 Apr 19 05:46 ../
-rwxr-xr-x 1 www-data www-data   14 Apr 19 05:46 .gitignore*
-rw-r--r-- 1 www-data www-data 3182 Apr 24 06:20 laravel.log

# cat storage/logs/laravel.log 
[2024-04-22 23:30:02] production.INFO: updating currencies  
[2024-04-23 06:20:02] production.INFO: Performing Autobilling 2024-04-23 06:20:02  
[2024-04-23 23:30:01] production.INFO: updating currencies  
[2024-04-24 06:20:01] production.INFO: Performing Autobilling 2024-04-24 06:20:01  

Can you please post a screenshot of the health check dialog?

bootstrap/cache/config.php was owned by root and so not writeable. Changed the ownership to www-data and run sudo -u www-data php artisan optimize. When trying to send an offer it’s still not send. Here’s the requested screenshot:

While digging around to search for possible errors I found the activity tab of the customer I am trying to email. There it says:
hokascha mailed offer [1692] for XXX to
24.04.2024 14:04 xxx.xxx.xxx.xxx

so it looks like there’s no recipient?!

Somehow I also received an eMail from IN now, that informs me of a new login source IP. So in general it looks like email sending works but still I cannot send invoices or offers.

Have you tried adding your email as a client and emailing yourself an invoice?

Yes, all the testing I am doing right now is using my own email address as a client’s address.

Is it possible the email is in your spam folder?

No, as I have control over the email server I can confirm IN is not even connecting to the server to deliver email.

is there a way to make IN more verbose in debug logging?

From the screenshot it looks like you’re using the web app, you may want to try with the desktop app to see if there’s a difference.

After installing the desktop app and logging in, I get a clear warning stating the company is not yet activated. Clicking on that warning brings me to the company settings where there’s a switch to enable the company which also enables emails, recurring invoices etc. This should definitly be made clear in the docs and also the warning should appear in the web app! Additionally, migrated companies should be activated by default.

Glad to hear it’s sorted, thanks for your patience figuring it out.

Migrated companies need to initially be de-activated but I agree the warning should be added to the web app.

cc @david @ben

Thank you #hokascha for the heads up to check if the company is activated/enabled, I’ve been chasing why the test email works but I cannot send invoices/quotes etc for the last few hours.
As soon as I Activated the company in “settings/account management/overview” invoice/quote emails start working