如何在Yii2邮件程序中向多个收件人发送邮件?
此代码适用于多个收件人但无法正常工作.
$value = Yii::$app->mailer->compose() ->setFrom([$this->email => $this->name]) ->setTo(array($model->email_1,$model->email_2)) ->setSubject($model->status) ->setHtmlBody($model->description) ->send();
$value = Yii::$app->mailer->compose() ->setFrom([$this->email => $this->name]) ->setTo($model->email_1) ->setCc($model->email_2) ->setSubject($model->status) ->setHtmlBody($model->description) ->send();
我刚刚尝试了以下代码,它正在运行.
您的代码中唯一奇怪的东西似乎是在带有Array的setFrom中.
原文链接:https://www.f2er.com/php/137835.html您的代码中唯一奇怪的东西似乎是在带有Array的setFrom中.
Yii::$app->mailer->compose() ->setFrom('addrs1@gmail.com') ->setTo(array('addrs1@gmail.com','addrs2@hotmail.com')) ->setCc(array('addrs3@gmail.com')) ->setSubject('Sending Email') ->setTextBody('This is Plain text content') ->setHtmlBody('Please go to <a href="http://google.com/">GOOGLE</a>') ->send();
* Set the From address of this message. * * It is permissible for multiple From addresses to be set using an array. * * If multiple From addresses are used,you SHOULD set the Sender address and * according to RFC 2822,MUST set the sender address.
希望能帮助到你.