2amigos/yii2-usuario

sent email console and application

Opened this issue · 12 comments

What steps will reproduce the problem?

if I create the user from the console the welcome email arrives without problems, if instead I create the user from the application with the user manager, it tells me that it was not possible to send the email and the creation of the user fails. I have the same usuario settings in both console and application configs.

What is the expected result?

What do you get instead?

Which platform is this? Could it be a filesystem permission problem?

It's a vps Ubuntu 20.04 Server (64bit), what permission I've to check ? Thanks

Well it could be related to the permissions on runtime/* folder/files which when used from console are created with a user, but the httpd process is running with a different user and has no write permission (www-data usually).

Do you have any log of the failed action? Mailer settings are the same for web and console?

Do you have any log of the failed action? Mailer settings are the same for web and console?

I have to check in the runtime / log folder right ? Yes configs are the same.

Well it could be related to the permissions on runtime/* folder/files which when used from console are created with a user, but the httpd process is running with a different user and has no write permission (www-data usually).

as soon as i get home i will check the user with permissions, thanks.

runtime folder contents and permissions..
runtime_folder_content

In logs folder I've only app.log file.

Then check in the app.log if there's any error relevant to the e-mail failing to be sent.

were exempt from logs: rofl: now I comment the lines and regenerate the warning ...

[
            'class' => FileTarget::class,
            'except' => [
                'yii\base\application*',
                'yii\db\Command:*',
                'yii\db\Connection*',
                'yii\web\Session:*',
                'yii\web\HttpException:*',
                'yii\log\Dispatcher:*',
                'yii\mail\BaseMailer:*', // <------
                'yii\swiftmailer\Mailer:*', // <------
                'yii\web\HeadersAlreadySentException'
            ],
            //'categories' => ['yii\web\HttpException:404'],
            // tutti i levels
            'levels' => ['warning', 'info'],
            'fileMode' => 0777,
            'logVars' => [],
        ],

The app.log file told to me that in vendor/2amigos/yii2-usuario/src/User/Controller/AdminController.php at line 135, but without specifying anything else

The error seems to be this:
2021-10-04 20:17:26 [78.40.160.43][1][-][error][usuario] The view file does not exist: app/modules/usuario/views/mail/welcome.php
in /var/www/html/yii2-my-app/vendor/2amigos/yii2-usuario/src/User/Traits/MailAwareTrait.php:45

usuario it's a module that extend from this and the view exist in that path !!! what's happening to him ?!

I've "view" component configured (console + web) like:

return [
    'theme' => [
        'pathMap'   => [
            '@app/views' => '@app/views/themes/adminlte3/views',
            '@Da/User/resources/views' => '@app/modules/usuario/views'
        ]
    ]
];

[partially solved]
I had extended the class without '@' in the path

class MailService extends baseMailService implements ServiceInterface
{
     //protected $ viewPath = 'app/modules/usuario/views/mail';
     protected $ viewPath = '@app/modules/usuario/views/mail';
}

now I don't know why if I create user (without password) from application, it sends me an email where it tells me that the user has been created and that's it. If I create it from the console, the user (without password) sends me a more complete email communicating the auto-generated password as well.

now I don't know why if I create user (without password) from application, it sends me an email where it tells me that the user has been created and that's it. If I create it from the console, the user (without password) sends me a more complete email communicating the auto-generated password as well.

Is it possible the module config is different between web and console?

the only difference was this:
'generatePasswords' => true,
Now if I leave the password blank in the email it tells me the password to use but there are still two differences:

  1. instead of receiving from info@my-app-domain.com (from console works fine) I receive from the address my-account-for-test@gmail.com
  2. don't translate mail content.

thanks