yii2-usuario icon indicating copy to clipboard operation
yii2-usuario copied to clipboard

sent email console and application

Open paskuale75 opened this issue 2 years ago • 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?

paskuale75 avatar Oct 03 '21 16:10 paskuale75

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

tsdogs avatar Oct 04 '21 06:10 tsdogs

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

paskuale75 avatar Oct 04 '21 06:10 paskuale75

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).

tsdogs avatar Oct 04 '21 07:10 tsdogs

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

maxxer avatar Oct 04 '21 07:10 maxxer

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.

paskuale75 avatar Oct 04 '21 07:10 paskuale75

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.

paskuale75 avatar Oct 04 '21 07:10 paskuale75

runtime folder contents and permissions.. runtime_folder_content

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

paskuale75 avatar Oct 04 '21 11:10 paskuale75

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

tsdogs avatar Oct 04 '21 13:10 tsdogs

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

paskuale75 avatar Oct 04 '21 20:10 paskuale75

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.

paskuale75 avatar Oct 04 '21 20:10 paskuale75

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?

maxxer avatar Oct 08 '21 10:10 maxxer

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 [email protected] (from console works fine) I receive from the address [email protected]
  2. don't translate mail content.

thanks

paskuale75 avatar Oct 09 '21 05:10 paskuale75