首页 > 解决方案 > yii2 mandrill 邮件已发送但未插入包含

问题描述

如何使用 yii2 nickcv插件将包含插入到 mandrill 模板中。在这段代码中test.org是我的模板名称,我想插入到包含中。任何人都知道它。这是代码。

\Yii::$app->mailer
->compose('test.org')
->setTo('test@mail.com')
->setSubject($setSubject)
->send();

我只想像这样添加身体

$body = "Hi ,Testing here";

标签: phpemailtemplatesyii2mandrill

解决方案


你必须setHtmlBody像那样使用函数

$mailSent = Yii::$app->mailer
                ->compose($template_name)
                ->setFrom('test@mail.org')
                ->setTo($to_email)
                ->setSubject($setSubject)
                ->setHtmlBody($setTextBody['html'])
                ->send();
        return $mailSent;

推荐阅读