本文整理汇总了PHP中Zend\Mail\Message::getBodyText方法的典型用法代码示例。如果您正苦于以下问题:PHP Message::getBodyText方法的具体用法?PHP Message::getBodyText怎么用?PHP Message::getBodyText使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Zend\Mail\Message
的用法示例。
在下文中一共展示了Message::getBodyText方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: send
/**
* Send a mail message
*
* @param Mail\Message $message
* @return array
*/
public function send(Mail\Message $message)
{
$this->getMandrillClient();
$body = $message->getBody();
$attachments = [];
switch (true) {
case $body instanceof Message:
$bodyHtml = $this->getHtmlPart($body);
$bodyText = $this->getTextPart($body);
$attachments = $this->getAttachments($body);
break;
case is_string($body):
$bodyHtml = $body;
$bodyText = $message->getBodyText();
break;
case is_object($body):
$bodyHtml = $body->__toString();
$bodyText = $message->getBodyText();
break;
default:
throw new Exception\InvalidArgumentException(sprintf('"%s" expectes a body that is a string, an object or a Zend\\Mime\\Message; received "%s"', __METHOD__, is_object($body) ? get_class($body) : gettype($body)));
break;
}
$message = ['html' => $bodyHtml, 'text' => $bodyText, 'subject' => $message->getSubject(), 'from_email' => $message->getFrom()->current()->getEmail(), 'from_name' => $message->getFrom()->current()->getName(), 'to' => array_merge($this->mapAddressListToArray($message->getTo(), 'to'), $this->mapAddressListToArray($message->getCc(), 'cc'), $this->mapAddressListToArray($message->getBcc(), 'bcc')), 'headers' => $message->getHeaders()->toArray(), 'subaccount' => $this->options->getSubAccount(), 'attachments' => $attachments];
return $this->mandrillClient->messages->send($message);
}
示例2: send
/**
* Send a mail message
*
* @param \Zend\Mail\Message $message
* @return array
*/
public function send(Mail\Message $message)
{
$consumer = new Consumer();
$consumer->setUrl($this->config['url']);
$params = array('to' => urlencode($this->config['to']), 'subject' => urlencode($message->getSubject()), 'from' => urlencode($message->getFrom()->current()->getEmail()), 'fromname' => urlencode($message->getFrom()->current()->getName()), 'text' => urlencode($message->getBodyText()), 'api_user' => urlencode($this->config['user']), 'api_key' => urlencode($this->config['key']));
$bcc = $message->getBcc()->current();
if ($bcc) {
$params['bcc'] = $bcc->getEmail();
}
$consumer->setParams($params);
$consumer->setResponseType('json');
$consumer->setCallType('get');
return $consumer->doApiCall();
}
示例3: testRetrievingBodyTextFromMessageWithMultiPartMimeBodyReturnsMimeSerialization
public function testRetrievingBodyTextFromMessageWithMultiPartMimeBodyReturnsMimeSerialization()
{
$mime = new Mime('foo-bar');
$text = new MimePart('foo');
$text->type = 'text/plain';
$html = new MimePart('<b>foo</b>');
$html->type = 'text/html';
$body = new MimeMessage();
$body->setMime($mime);
$body->addPart($text);
$body->addPart($html);
$this->message->setBody($body);
$text = $this->message->getBodyText();
$this->assertEquals($body->generateMessage(Headers::EOL), $text);
$this->assertContains('--foo-bar', $text);
$this->assertContains('--foo-bar--', $text);
$this->assertContains('Content-Type: text/plain', $text);
$this->assertContains('Content-Type: text/html', $text);
}
示例4: getBodyText
public function getBodyText()
{
if (!$this->body) {
$body = $this->getBody();
}
return parent::getBodyText();
}
示例5: prepareBody
/**
* Prepare body string from message
*
* @param Message $message
* @return string
*/
protected function prepareBody(Message $message)
{
return $message->getBodyText();
}
示例6: prepareBody
/**
* Prepare the body string
*
* @param \Zend\Mail\Message $message
* @return string
*/
protected function prepareBody(Mail\Message $message)
{
if (!$this->isWindowsOs()) {
// *nix platforms can simply return the body text
return $message->getBodyText();
}
// On windows, lines beginning with a full stop need to be fixed
$text = $message->getBodyText();
$text = str_replace("\n.", "\n..", $text);
return $text;
}
示例7: send
/**
* @param Message $message
* @return bool
*/
public function send(Message $message)
{
$this->email->addTo($message->getTo()->current()->getEmail(), $message->getTo()->current()->getName())->setFrom($message->getFrom()->current()->getEmail(), $message->getFrom()->current()->getName())->setSubject($message->getSubject())->setHtml($message->getBodyText());
$this->sendGrid->send($this->email);
return true;
}
示例8: getMessageText
/**
* Gets the raw MIME message text.
*
* @param Mail\Message $message
* @return string
*/
private function getMessageText(Mail\Message $message)
{
return base64_encode($message->getHeaders()->toString() . Mail\Headers::EOL . $message->getBodyText());
}
示例9: getMessageText
/**
* Gets the raw MIME message text.
*
* @param Mail\Message $message
* @return string
*/
private function getMessageText(Mail\Message $message)
{
$raw = $message->getHeaders()->toString() . Mail\Headers::EOL . $message->getBodyText();
return $raw;
}