Search code examples
phpemailtemplatesyii2mandrill

yii2 mandrill mail is sent but not insert contain


How to insert contain into mandrill template using yii2 nickcv plugin. in this code test.org is my template name and i want to insert into contain. anyone have idea about it. This is the code.

\Yii::$app->mailer
->compose('test.org')
->setTo('[email protected]')
->setSubject($setSubject)
->send();

i just want to add body like this

$body = "Hi ,Testing here";

Solution

  • You have to use setHtmlBody function just like that

    $mailSent = Yii::$app->mailer
                    ->compose($template_name)
                    ->setFrom('[email protected]')
                    ->setTo($to_email)
                    ->setSubject($setSubject)
                    ->setHtmlBody($setTextBody['html'])
                    ->send();
            return $mailSent;