本文整理汇总了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;
}