SMTP Mail error (Undefined variable: support_message (View: /resources/views/email/support/message.blade.php)

Hello everyone, i’m trying to install Invoiceninja v5.2.8. But i get the following error:
Undefined variable: support_message (View: /www/wwwroot/administratiev5.jmsites.tk/resources/views/email/support/message.blade.php)
image

I have tried to set it to “log” in the installation and later on changed it to “smtp” in the .env file as described here. But this doesn’t work either. The “system log” from the GUI gives an error with email, but the log itself is empty.

In the Laravel.log file appears the following error:
[2021-07-12 12:00:53] production.ERROR: Mailer [SMTP] is not defined. {“exception”:"[object] (InvalidArgumentException(code: 0): Mailer [SMTP] is not defined. at /www/wwwroot/administratie.jmsites.tk/vendor/laravel/framework/src/Illuminate/Mail/MailManager.php:110)
[stacktrace]

I have tried to connect to another SMTP server (Gmail), but this doesn’t work either.
How can i fix this issue?

Kind regards.

Hi,

The latest version is v5.2.11, it may help.

Hi,

Thanks for your response.
I have tried this version. But it gives the same result.

Do you have any other idea how to fix this?

Thanks in advance

How have you installed the application?

I have installed the application on my web server.
This web server is a Ubuntu 20.04.2 server with Openlitespeed, PHP 7.3 and mysql-mariadb 10.4.14

Hope you have enough information with this, if you need more let me know

Hi jornmeijs

Can you run the following:

cat VERSION.txt

And advise the output please

Then run the following combination

composer i -o
php artisan clear-compiled
php artisan optimize

Hi David,

Here are the outputs:
cat VERSION.txt:
5.2.11

composer i -o:
Warning: This development build of composer is over 60 days old. It is recommended to update it by running “/usr/bin/composer self-update” to get the latest version.
Do not run Composer as root/super user! See https://getcomposer.org/root for details
Loading composer repositories with package information
Installing dependencies (including require-dev) from lock file
Your requirements could not be resolved to an installable set of packages.

Problem 1
- Installation request for facade/ignition 2.10.2 → satisfiable by facade/ignition[2.10.2].
- facade/ignition 2.10.2 requires ext-mbstring * → the requested PHP extension mbstring is missing from your system.
Problem 2
- Installation request for phpunit/phpunit 9.5.6 → satisfiable by phpunit/phpunit[9.5.6].
- phpunit/phpunit 9.5.6 requires ext-mbstring * → the requested PHP extension mbstring is missing from your system.
Problem 3
- Installation request for vimeo/psalm 4.8.1 → satisfiable by vimeo/psalm[4.8.1].
- vimeo/psalm 4.8.1 requires ext-mbstring * → the requested PHP extension mbstring is missing from your system.
Problem 4
- authorizenet/authorizenet 2.0.2 requires ext-curl * → the requested PHP extension curl is missing from your system.
- authorizenet/authorizenet 2.0.2 requires ext-curl * → the requested PHP extension curl is missing from your system.
- Installation request for authorizenet/authorizenet 2.0.2 → satisfiable by authorizenet/authorizenet[2.0.2].

To enable extensions, verify that they are enabled in your .ini files:
- /etc/php/7.4/cli/php.ini
- /etc/php/7.4/cli/conf.d/10-opcache.ini
- /etc/php/7.4/cli/conf.d/10-pdo.ini
- /etc/php/7.4/cli/conf.d/15-xml.ini
- /etc/php/7.4/cli/conf.d/20-calendar.ini
- /etc/php/7.4/cli/conf.d/20-ctype.ini
- /etc/php/7.4/cli/conf.d/20-dom.ini
- /etc/php/7.4/cli/conf.d/20-exif.ini
- /etc/php/7.4/cli/conf.d/20-ffi.ini
- /etc/php/7.4/cli/conf.d/20-fileinfo.ini
- /etc/php/7.4/cli/conf.d/20-ftp.ini
- /etc/php/7.4/cli/conf.d/20-gettext.ini
- /etc/php/7.4/cli/conf.d/20-iconv.ini
- /etc/php/7.4/cli/conf.d/20-json.ini
- /etc/php/7.4/cli/conf.d/20-phar.ini
- /etc/php/7.4/cli/conf.d/20-posix.ini
- /etc/php/7.4/cli/conf.d/20-readline.ini
- /etc/php/7.4/cli/conf.d/20-shmop.ini
- /etc/php/7.4/cli/conf.d/20-simplexml.ini
- /etc/php/7.4/cli/conf.d/20-sockets.ini
- /etc/php/7.4/cli/conf.d/20-sysvmsg.ini
- /etc/php/7.4/cli/conf.d/20-sysvsem.ini
- /etc/php/7.4/cli/conf.d/20-sysvshm.ini
- /etc/php/7.4/cli/conf.d/20-tokenizer.ini
- /etc/php/7.4/cli/conf.d/20-xmlreader.ini
- /etc/php/7.4/cli/conf.d/20-xmlwriter.ini
- /etc/php/7.4/cli/conf.d/20-xsl.ini
You can also run php --ini inside terminal to see which files are used by PHP in CLI mode.

php artisan clear-compiled:
Compiled services and packages files removed!

php artisan optimize:
Configuration cache cleared!
Configuration cached successfully!
Route cache cleared!
Routes cached successfully!
Files cached successfully!

Hope this contains the information you need.

Thanks in advance.

Can you confirm you are using Comoser v1 or Composer v2?

This looks like the output I would expect from v1… For Invoice Ninja v5, we need Composer V2.

How do i check the Comoser version? I’m not that familiar with Comoser :slight_smile:

composer -V

https://getcomposer.org/doc/00-intro.md

Thanks,

I was running version 1. I have now updated to version 2.1.3. I will check if this fixes the problem, if so, i will let you know.

Thanks in advance

I have tried, but i get the same error. I have also installed the newest version V5.2.11, but i get the same result. Do you have any other ideas?

@jornmeijs

Something looks really broken there.

Can you do a fresh git pull from the repo and try again.

I am having the same problem too.

Fresh install of 5.2.14. Installation method was with git, but the command was slightly different.

git clone https://github.com/invoiceninja/invoiceninja.git --depth 1 --branch v5-stable --single-branch

Running on a shared host. PHP 7.3.27. Composer 2.0.6. Trying to send using SMTP with Mailgun SMTP credentials. Fails for both encryption types and all ports Mailgun SMTP supports. Sendmail and Mail methods are failing also with the same error.

I don’t really know if the server has all the required PHP modules. I presumed the installation had preflight checks that would identify anything missing.

/opt/cpanel/ea-php73/root/etc/php.d/20-bcmath.ini,
/opt/cpanel/ea-php73/root/etc/php.d/20-bz2.ini,
/opt/cpanel/ea-php73/root/etc/php.d/20-calendar.ini,
/opt/cpanel/ea-php73/root/etc/php.d/20-ctype.ini,
/opt/cpanel/ea-php73/root/etc/php.d/20-curl.ini,
/opt/cpanel/ea-php73/root/etc/php.d/20-dba.ini,
/opt/cpanel/ea-php73/root/etc/php.d/20-dom.ini,
/opt/cpanel/ea-php73/root/etc/php.d/20-enchant.ini,
/opt/cpanel/ea-php73/root/etc/php.d/20-exif.ini,
/opt/cpanel/ea-php73/root/etc/php.d/20-fileinfo.ini,
/opt/cpanel/ea-php73/root/etc/php.d/20-ftp.ini,
/opt/cpanel/ea-php73/root/etc/php.d/20-gd.ini,
/opt/cpanel/ea-php73/root/etc/php.d/20-gettext.ini,
/opt/cpanel/ea-php73/root/etc/php.d/20-gmp.ini,
/opt/cpanel/ea-php73/root/etc/php.d/20-iconv.ini,
/opt/cpanel/ea-php73/root/etc/php.d/20-imap.ini,
/opt/cpanel/ea-php73/root/etc/php.d/20-intl.ini,
/opt/cpanel/ea-php73/root/etc/php.d/20-json.ini,
/opt/cpanel/ea-php73/root/etc/php.d/20-ldap.ini,
/opt/cpanel/ea-php73/root/etc/php.d/20-mbstring.ini,
/opt/cpanel/ea-php73/root/etc/php.d/20-mysqlnd.ini,
/opt/cpanel/ea-php73/root/etc/php.d/20-odbc.ini,
/opt/cpanel/ea-php73/root/etc/php.d/20-pdo.ini,
/opt/cpanel/ea-php73/root/etc/php.d/20-pgsql.ini,
/opt/cpanel/ea-php73/root/etc/php.d/20-phar.ini,
/opt/cpanel/ea-php73/root/etc/php.d/20-posix.ini,
/opt/cpanel/ea-php73/root/etc/php.d/20-pspell.ini,
/opt/cpanel/ea-php73/root/etc/php.d/20-shmop.ini,
/opt/cpanel/ea-php73/root/etc/php.d/20-simplexml.ini,
/opt/cpanel/ea-php73/root/etc/php.d/20-soap.ini,
/opt/cpanel/ea-php73/root/etc/php.d/20-sockets.ini,
/opt/cpanel/ea-php73/root/etc/php.d/20-sqlite3.ini,
/opt/cpanel/ea-php73/root/etc/php.d/20-sysvmsg.ini,
/opt/cpanel/ea-php73/root/etc/php.d/20-sysvsem.ini,
/opt/cpanel/ea-php73/root/etc/php.d/20-sysvshm.ini,
/opt/cpanel/ea-php73/root/etc/php.d/20-tokenizer.ini,
/opt/cpanel/ea-php73/root/etc/php.d/20-xml.ini,
/opt/cpanel/ea-php73/root/etc/php.d/20-xmlwriter.ini,
/opt/cpanel/ea-php73/root/etc/php.d/20-xsl.ini,
/opt/cpanel/ea-php73/root/etc/php.d/20-zip.ini,
/opt/cpanel/ea-php73/root/etc/php.d/30-mysqli.ini,
/opt/cpanel/ea-php73/root/etc/php.d/30-pdo_mysql.ini,
/opt/cpanel/ea-php73/root/etc/php.d/30-pdo_odbc.ini,
/opt/cpanel/ea-php73/root/etc/php.d/30-pdo_pgsql.ini,
/opt/cpanel/ea-php73/root/etc/php.d/30-pdo_sqlite.ini,
/opt/cpanel/ea-php73/root/etc/php.d/30-wddx.ini,
/opt/cpanel/ea-php73/root/etc/php.d/30-xmlreader.ini,
/opt/cpanel/ea-php73/root/etc/php.d/30-xmlrpc.ini,
/opt/cpanel/ea-php73/root/etc/php.d/zzzzzzz-pecl.ini

I should add that laravel.log is empty

@hunterwebs are you seeing the same error?

“Undefined variable: support_message”

Yes, same error.

Undefined variable: support_message (View: /[pathtofolder]/resources/views/email/support/message.blade.php)

@david any thoughts?

The file:
/app/Mail/TestMailServer.php

    public function build()
    {
        return $this->from(config('mail.from.address'), config('mail.from.name'))
            ->subject(ctrans('texts.email'))
            ->markdown('email.support.message', [
                'message' => $this->message,
                'system_info' => '',
                'laravel_log' => [],
            ]);
    }

Makes no reference to support_message.

Additionally, changing message to support_message changes the error.

Connection could not be established with host smtp.mailtrap.io :stream_socket_client(): unable to connect to smtp.mailtrap.io:2525 (Connection refused)

But the details inputted are SMTP details for Mailgun. Looks like the app is still using the values within .env which are set to mailtrap.

MAIL_MAILER=smtp
MAIL_HOST=smtp.mailtrap.io
MAIL_PORT=2525
MAIL_USERNAME=null
MAIL_PASSWORD=null
MAIL_ENCRYPTION=null
MAIL_FROM_ADDRESS='user@example.com'
MAIL_FROM_NAME='Self Hosted User'

As per installation instructions: cp .env.example .env which has those values by default.

EDIT:

    public function build()
    {
		
		die(config('mail.host'));
        return $this->from(config('mail.from.address'), config('mail.from.name'))
            ->subject(ctrans('texts.email'))
            ->markdown('email.support.message', [
                'support_message' => $this->message,
                'system_info' => '',
                'laravel_log' => [],
            ]);
    }

Returns desired result of smtp.mailgun.org

Is this related: php - Laravel - changing email settings on the fly is not working - Stack Overflow

Technically two problems going on there. Surprised to see it’s not effecting more people

@hunterwebs

I’ve checked in a fix for the first issue. The second one I don’t think is an issue as we set the config dynamically

    public static function testMailServer($request = null)
    {
        if ($request->driver == 'log') {
            return [];
        }

        if ($request) {
            config(['mail.driver' => $request->input('mail_driver')]);
            config(['mail.host' => $request->input('mail_host')]);
            config(['mail.port' => $request->input('mail_port')]);
            config(['mail.from.address' => $request->input('mail_address')]);
            config(['mail.from.name' => $request->input('mail_name')]);
            config(['mail.encryption' => $request->input('encryption')]);
            config(['mail.username' => $request->input('mail_username')]);
            config(['mail.password' => $request->input('mail_password')]);
        }

        try {
            Mail::to(config('mail.from.address'))->send(new TestMailServer('Email Server Works!', config('mail.from.address')));
        } catch (Exception $e) {
            return ['success' => false, 'message' => $e->getMessage()];
        }

        return ['success' => true];
    }