本文整理匯總了PHP中EmailMessage::setMessage方法的典型用法代碼示例。如果您正苦於以下問題:PHP EmailMessage::setMessage方法的具體用法?PHP EmailMessage::setMessage怎麽用?PHP EmailMessage::setMessage使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類EmailMessage
的用法示例。
在下文中一共展示了EmailMessage::setMessage方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: createModel
/**
* Creates a model from the given Swift_Message instance and saves it.
* @param Swift_Message $message
* @param string $contentType
* @param string $charset
* @return EmailMessage the model.
*/
protected function createModel(Swift_Message $message, $contentType, $charset)
{
$model = new EmailMessage();
$model->setMessage($message);
$model->from = implode(', ', array_keys($message->getFrom()));
$model->to = implode(', ', array_keys($message->getTo()));
$cc = $message->getCc();
if (is_array($cc)) {
$model->cc = implode(', ', $cc);
}
$bcc = $message->getBcc();
if (is_array($bcc)) {
$model->bcc = implode(', ', $bcc);
}
$model->subject = $message->getSubject();
$model->body = $message->getBody();
$model->headers = implode("\n", $message->getHeaders()->getAll());
$model->contentType = $contentType;
$model->charset = $charset;
$model->save(false);
// need to save the model to get its id.
$model->body = str_replace('{viewUrl}', $this->createViewUrl($model), $model->body);
$model->save(false);
return $model;
}