此外,您可以通過Yii :: app-> mailer-> newMessage創建消息。 這允許您設置電子郵件消息值。 例如:
$emailAddresses = array(
'to' => array('[email protected]','[email protected]'),
'bcc' => array('multiple emails','separated','by','commas'),
'reply' => $replyEmail,
);
// Generate the message with appropriate fields
$message = Yii::app->mailer->newMessage; //Swift_Message::newInstance()
$message->setSubject($subject);
$message->setFrom(array($emailAddress => 'administration'));
$message->setTo($emailAddresses['to']);
$message->setBcc($emailAddresses['bcc']);
$message->setReplyTo($emailAddresses['reply']);
$message->setBody('<h1>'.$header.'</h1><p>'.$bodyHtml,'text/html');
//Send message
$mailer = Yii::app()->mailer->getInstance($email);
$mailer->send($message,$failures);