Configure and rewrite the $viewPath property in the mail file in the module.
example:
public $viewPath = '@myvendor/mymodule/mail';
First, create new html and text files. Create both files.
Create both files.
- mail/newHTML
mail/trxt/NewTEXT
$mailer = Yii::$app->mailer;
$mailer->viewPath = $this->viewPath;
$mailer->getView()->theme = Yii::$app->view->theme;
return $mailer->compose(['html' => $view, 'text' => 'text/' . $view], $params)
->setTo($to)
->setFrom($this->sender)
->setSubject($subject)
->send();
If you want to change the path for only one:
Use before code:
Yii :: $ app-> mailer-> viewPath = '@ myvendor / newPath';
Yii::$app->mailer->compose([ #code...
If the VIEW file: Only need to change the name for HTML and TEXT file, (both)
Update:
It can be override or through a component and ...
//new file: path\widgets\Mailer.php
namespace path\widgets;
use yourpath\Mailer as DefaultMailer; //path:mymodule/mail
class Mailer extends DefaultMailer{
public $viewPath = '@myvendor/mymodule/mail';
public function changeviewPath($_path){
$this->viewPath; = $_path;
}
}
// for use. Changes
use path\widgets\Maile; // New path
// Use before the usual code
$mailer->changeviewPath('newpath\mail');
To change the address of the files in the component. Depending on your email module, it varies
example:
'modules' => [
'myMudul' => [
'class' => 'PathModule\Module',
'mailer' => [
#code ..
],
],
...