Yii2: how to pretend in mail
I can send mail using the swiftmailer extension. I can also include a view file from the @ app / mail folder.
Now I am wondering how I can include data for my models, for example, for example I have Model City.php and an associated view as view.php or index.php (grid-view), how can I include data, received in view.php (single entry) or table data in index.php in the body of the email.
In short, I want to include the default data presented in yii2 in views or index in the body of the email.
Hi I have seen this example as - Yii::$app->mailer->compose('viewName', ['variable' => $variable])
another example - Yii::$app->mailer->compose('contact/html', ['contactForm' => $form])
I've tried this without much success:
Yii::$app->mailer->compose('medicine-request-entry/html',['medicine_request_entry'=>$form])
but I am getting the variable variable undefined. medicie_request_entry
is a folder in the views folder. (not in @ app / views)
but couldn't get it. Let's say the name of my view in / mail / subfolder says report.php and I have a folder in my signatures views / city / and the city folder has view.php and index.php, how can I specify this in a parameter in the example code ...
Any suggestion would be greatly appreciated.
Thank.
source to share
Ok I found a solution and provided an answer for those with the same difficulty
I changed the code in my controller, for example:
Yii::$app->mailer->compose('@app/views/medicine-request-entry/view',['model'=>$model])
But I still didn't get how to use the layout specified in @app/mail
or send mail as html.
Thank.
source to share