Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sent email console and application #438

Open
paskuale75 opened this issue Oct 3, 2021 · 12 comments
Open

sent email console and application #438

paskuale75 opened this issue Oct 3, 2021 · 12 comments

Comments

@paskuale75
Copy link

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?

@tsdogs
Copy link
Contributor

tsdogs commented Oct 4, 2021

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

@paskuale75
Copy link
Author

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

@tsdogs
Copy link
Contributor

tsdogs commented Oct 4, 2021

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

@maxxer
Copy link
Collaborator

maxxer commented Oct 4, 2021

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

@paskuale75
Copy link
Author

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
Copy link
Author

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
Copy link
Author

paskuale75 commented Oct 4, 2021

runtime folder contents and permissions..
runtime_folder_content

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

@tsdogs
Copy link
Contributor

tsdogs commented Oct 4, 2021

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

@paskuale75
Copy link
Author

paskuale75 commented Oct 4, 2021

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
Copy link
Author

paskuale75 commented Oct 4, 2021

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.

@maxxer
Copy link
Collaborator

maxxer commented Oct 8, 2021

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?

@paskuale75
Copy link
Author

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants