A
A
Andy-shak2016-02-24 23:29:47
Yii
Andy-shak, 2016-02-24 23:29:47

Is it possible to include a php mail send file in Yii2?

There is an html form in view in yii2 and there is a php file to send a message to the mail. How to include this php file in html form?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
V
Vladimir Soldatov, 2016-02-25
@TPbIHTPABA

Isn't it easier to use swiftmailer?

/*в конфиге*/

'components' => [
        'mail' => [
            'class' => 'yii\swiftmailer\Mailer',
        ],
]

/*где нужно отправить письмо*/

$mail = Yii::$app->mail;
$mail->htmlLayout = "layouts/admin";
$mail->compose('@app/mail/changePassword/html.php', $arParams)
         ->setFrom(['[email protected]' => Yii::$app->name])
          ->setTo($this->email)
          ->setSubject('Восстановление пароля на сайте ' . Yii::$app->name)
          ->send();
/*$arParams - параметры передаваемые в шаблон письма*/

If you really want to connect your code, then I advise you to arrange it as a component and connect it in the same way as swiftmailer.

D
Danil Sysoev, 2016-02-24
@YoungOldMan

It is a question of connection of a file with a class of sending mail? require?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question