The view file does not exist - where do mail layouts go

I am using basic template but have adapted the advanced user password reset functionality, for some reason I can’t get it to find the mail layouts.

So in \mail\layouts I have

  • passwordResetToken-html.php

  • passwordResteToken-text.php

In web.php I have

'mailer' => [

            'class' => 'yii\swiftmailer\Mailer',

            'viewPath' => 'app\mail\layouts',


The advanced template uses

'viewPath' => '@common/mail',

But as i’m using basic template, its not in the common/mail folder.

In sendMail function in PasswordResetRequestForm.php i have

return \Yii::$app->mailer->compose(['html' => 'passwordResetToken-html', 'text' => 'passwordResetToken-text'], ['user' => $user])


However getting error

The view file does not exist: app\mail\layouts\passwordResetToken-html.php

I know this is going to be something small but for the life of me i cannot see it :)

Any help please on how to set the viewpath ?

It should be

 'viewPath' => '@app\mail\layouts',

@app - is an alias to your "root" folder, you can check exact folder in config in "aliases" section

If you put path without @, Yii just search an ‘app’ folder which obviously not exists, more over it searches in folder where index.php resides

thanks , but i tried that and its giving me error

Invalid Parameter – yii\base\InvalidParamException

Invalid path alias: @app\mail\layouts

i moved the view files up a level to /mail and then i get bizarre location error of:

The view file does not exist: C:\wamp\www\mysite/mail\passwordResetToken-html.php

Thats using

'viewPath' => '@app/mail',

must be something else i’m missing/doing wrong ? :(

Where exactly is your passwordResetToken-html.php located now?

Is it in "C:\wamp\www\mysite\mail"?

And I’m wondering what do you do with the layouts.

The original app-advanced template uses the following views and layouts.








It is located exactly in


I have tried it also at


So, currently this does not work

'viewPath' => '@app/mail/layouts',

Yes, the app-advanced in @common was working when I initially created my app using the advanced template. So adapting it to basic and locating it correctly is the problem :(

Any suggestions ?

If you have transplanted the views for mail from app-advanced to app-basic without much modification, then your @app/mail directory should be like this:








I mean, @app/mail should contain "" and "passwordResetToken-text.php", and @app/mail/layouts should contain "html.php" and "text.php".

And your config should be

'viewPath' => '@app/mail',

Thank you !

Finally !

What i had missed was the actual /layouts/html.php and text.php files when i copied the others across !

So simple :-[