|
- <?php
-
- namespace backend\models;
-
- use Yii;
- use yii\base\Model;
-
-
- class MailForm extends Model
- {
- public $subject;
- public $body;
-
-
-
- public function rules()
- {
- return [
-
- [['subject', 'body'], 'required', 'message' => 'Champs obligatoire'],
- ];
- }
-
-
-
- public function attributeLabels()
- {
- return [
- 'subject' => 'Sujet',
- 'body' => 'Message',
- ];
- }
-
-
-
- public function sendEmail($email)
- {
-
- return Yii::$app->mailer->compose()
- ->setTo($email)
- ->setFrom(['matthieu@lechatdesnoisettes.com' => 'Le Chat des Noisettes'])
- ->setSubject($this->subject)
- ->setTextBody($this->body)
- ->send();
- }
- }
|