此外,您可以通过 Yii::app->mailer->newMessage. 创建消息。这允许您设置电子邮件消息值。例如:
$emailAddresses = array(
'to' => array('email@blah.com','email2@blah.com'),
'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);