本文整理汇总了PHP中Zend_Mail::getBodyText方法的典型用法代码示例。如果您正苦于以下问题:PHP Zend_Mail::getBodyText方法的具体用法?PHP Zend_Mail::getBodyText怎么用?PHP Zend_Mail::getBodyText使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Zend_Mail
的用法示例。
在下文中一共展示了Zend_Mail::getBodyText方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: _buildBody
/**
* Generate MIME compliant message from the current configuration
*
* If both a text and HTML body are present, generates a
* multipart/alternative Zend_Mime_Part containing the headers and contents
* of each. Otherwise, uses whichever of the text or HTML parts present.
*
* The content part is then prepended to the list of Zend_Mime_Parts for
* this message.
*
* @return void
*/
protected function _buildBody()
{
if (($text = $this->_mail->getBodyText())
&& ($html = $this->_mail->getBodyHtml()))
{
// Generate unique boundary for multipart/alternative
$mime = new Zend_Mime(null);
$boundaryLine = $mime->boundaryLine($this->EOL);
$boundaryEnd = $mime->mimeEnd($this->EOL);
$text->disposition = false;
$html->disposition = false;
$body = $boundaryLine
. $text->getHeaders($this->EOL)
. $this->EOL
. $text->getContent($this->EOL)
. $this->EOL
. $boundaryLine
. $html->getHeaders($this->EOL)
. $this->EOL
. $html->getContent($this->EOL)
. $this->EOL
. $boundaryEnd;
$mp = new Zend_Mime_Part($body);
$mp->type = Zend_Mime::MULTIPART_ALTERNATIVE;
$mp->boundary = $mime->boundary();
$this->_isMultipart = true;
// Ensure first part contains text alternatives
array_unshift($this->_parts, $mp);
// Get headers
$this->_headers = $this->_mail->getHeaders();
return;
}
// If not multipart, then get the body
if (false !== ($body = $this->_mail->getBodyHtml())) {
array_unshift($this->_parts, $body);
} elseif (false !== ($body = $this->_mail->getBodyText())) {
array_unshift($this->_parts, $body);
}
if (!$body) {
throw new Zend_Mail_Transport_Exception('No body specified');
}
// Get headers
$this->_headers = $this->_mail->getHeaders();
$headers = $body->getHeadersArray($this->EOL);
foreach ($headers as $header) {
// Headers in Zend_Mime_Part are kept as arrays with two elements, a
// key and a value
$this->_headers[$header[0]] = array($header[1]);
}
}
示例2: send
public function send($template, array $values = array())
{
// create a new mail
$mail = new Zend_Mail('UTF-8');
if (isset($values['to'])) {
if (is_array($values['to'])) {
foreach ($values['to'] as $address) {
$mail->addTo($address);
}
} else {
$mail->addTo($values['to']);
}
unset($values['to']);
} else {
throw new Exception('to not send in $values');
}
// set cc
if (isset($values['cc'])) {
if (is_array($values['cc'])) {
foreach ($values['cc'] as $address) {
$mail->addCc($address);
}
} else {
$mail->addCc($values['cc']);
}
unset($values['cc']);
}
// set bcc
if (isset($values['bcc'])) {
if (is_array($values['bcc'])) {
foreach ($values['bcc'] as $address) {
$mail->addBcc($address);
}
} else {
$mail->addBcc($values['bcc']);
}
unset($values['bcc']);
}
// get the template
$templateModel = new Core_Model_Templates();
$data = $templateModel->show($template, $values);
// set subject and body
$mail->setSubject($data['subject']);
$mail->setBodyText($data['body']);
if (empty(Daiquiri_Config::getInstance()->mail->debug)) {
$mail->send();
} else {
Zend_Debug::dump($mail->getRecipients());
Zend_Debug::dump($mail->getSubject());
Zend_Debug::dump($mail->getBodyText());
}
}
示例3: sendMessage
/**
* Send a mail using this transport
*
* @return void
* @throws \Magento\Framework\Exception\MailException
*/
public function sendMessage()
{
try {
$sendpulseClient = null;
$recipients = implode(',', $this->_message->getRecipients());
$parameters = array('from' => $this->_message->getFrom(), 'to' => $recipients, 'subject' => quoted_printable_decode($this->_message->getSubject()), 'text' => quoted_printable_decode($this->_message->getBodyText(true)), 'html' => quoted_printable_decode($this->_message->getBodyHtml(true)));
// TODO add attachment support
$attachments = array();
/*
$attachments = array(
'attachment' => array(
'/path/to/file.txt',
'/path/to/file.txt'
)
);
*/
# Make the call to the client.
$result = $sendpulseClient->sendMessage($this->_config->getMailgunDomain(), $parameters, $attachments);
} catch (\Exception $e) {
throw new \Magento\Framework\Exception\MailException(new \Magento\Framework\Phrase($e->getMessage()), $e);
}
}
示例4: mailProvider
public function mailProvider()
{
$data = array();
$mail = new Zend_Mail();
$mail->setSubject('Some Mail to log');
$mail->addTo('email@example.com');
$mail->setBodyText('Some Text');
$mail->setBodyHtml('<div>Some Html</div>');
$message = 'Subject: ' . $mail->getSubject() . PHP_EOL;
$message .= 'To: ' . implode(', ', $mail->getRecipients()) . PHP_EOL;
$message .= 'Text: ' . $mail->getBodyText()->getContent() . PHP_EOL . PHP_EOL;
$message .= 'Html: ' . $mail->getBodyHtml()->getContent();
$data[] = array($mail, $message);
return $data;
}
示例5: getBodyHtml
public function getBodyHtml($htmlOnly = false)
{
if ($htmlOnly) {
return parent::getBodyHtml(true);
}
$mime = new Zend_Mime($this->getMimeBoundary());
$boundaryLine = $mime->boundaryLine($this->EOL);
$boundaryEnd = $mime->mimeEnd($this->EOL);
$html = parent::getBodyHtml();
$text = parent::getBodyText();
$text->disposition = false;
$html->disposition = false;
$body = $boundaryLine . $text->getHeaders($this->EOL) . $this->EOL . $text->getContent($this->EOL) . $this->EOL . $boundaryLine . $html->getHeaders($this->EOL) . $this->EOL . $html->getContent($this->EOL) . $this->EOL . $boundaryEnd;
$mp = new Zend_Mime_Part($body);
$mp->type = Zend_Mime::MULTIPART_ALTERNATIVE;
$mp->boundary = $mime->boundary();
return $mp;
}
示例6: sendMessage
/**
* Send a mail using this transport
*
* @return void
* @throws \Magento\Framework\Exception\MailException
*/
public function sendMessage()
{
try {
/** @var Client $client */
$client = new Client();
/** @var $mailgunClient Mailgun */
$mailgunClient = new Mailgun($this->_config->getMailgunKey(), $client);
/** @var string $recipients comma separated */
$recipients = implode(',', $this->_message->getRecipients());
// Assign default parameters
$parameters = array('from' => $this->_message->getFrom(), 'to' => $recipients, 'subject' => $this->decodeZendQuotedPrintableHeader($this->_message->getSubject()), 'text' => quoted_printable_decode($this->_message->getBodyText(true)), 'html' => quoted_printable_decode($this->_message->getBodyHtml(true)));
$parameters = $this->assignOptionalParameters($parameters);
/** @var array $postFiles */
$postFiles = $this->getPostFiles();
$domain = $this->_config->getMailgunDomain();
$result = $mailgunClient->sendMessage($domain, $parameters, $postFiles);
$this->getMail()->setResult($result);
$this->getMail()->setSent($this->createSent())->setSentAt($this->createSentAt())->setTransportId($this->createTransportId());
} catch (\Exception $e) {
throw new \Magento\Framework\Exception\MailException(new \Magento\Framework\Phrase($e->getMessage()), $e);
}
}
示例7: sendUsingZendMail
protected static function sendUsingZendMail($transport = null)
{
ProjectConfiguration::registerZend();
$mail = new Zend_Mail();
$mail->addHeader('X-MailGenerator', ProjectConfiguration::getApplicationName());
$mail->setBodyText(self::$_message);
$mail->setBodyHtml(self::$_html_message);
$mail->setFrom(self::$_from);
if (is_array(self::$_to)) {
foreach (self::$_to as $send_to) {
$mail->addTo($send_to);
}
} else {
$mail->addTo(self::$_to);
}
$mail->setSubject(self::$_subject);
if (sfConfig::get('sf_environment') != 'prod') {
if (sfConfig::get('sf_logging_enabled')) {
sfContext::getInstance()->getLogger()->info('Mail sent: ' . $mail->getBodyText()->getRawContent());
}
return false;
}
return $mail->send($transport);
}
示例8: _buildBody
/**
* Generate MIME compliant message from the current configuration
*
* If both a text and HTML body are present, generates a
* multipart/alternative Zend_Mime_Part containing the headers and contents
* of each. Otherwise, uses whichever of the text or HTML parts present.
*
* The content part is then prepended to the list of Zend_Mime_Parts for
* this message.
*
* @return void
*/
protected function _buildBody()
{
// if (($text = $this->_mail->getBodyText())
// && ($html = $this->_mail->getBodyHtml()))
//
$text = $this->_mail->getBodyText();
$html = $this->_mail->getBodyHtml();
$htmlAttachments = $this->_mail->getHtmlRelatedAttachments();
$htmlAttachmentParts = $htmlAttachments->getParts();
$hasHtmlRelatedParts = count($htmlAttachmentParts);
if ($text && $html || $html && $hasHtmlRelatedParts && count($this->_parts)) {
// Generate unique boundary for multipart/alternative
$mime = new Zend_Mime(null);
$boundaryLine = $mime->boundaryLine($this->EOL);
$boundaryEnd = $mime->mimeEnd($this->EOL);
// $text->disposition = false;
$html->disposition = false;
// $body = $boundaryLine
// . $text->getHeaders($this->EOL)
// . $this->EOL
// . $text->getContent($this->EOL)
// . $this->EOL
// . $boundaryLine
// . $html->getHeaders($this->EOL)
if ($hasHtmlRelatedParts) {
$message = new Zend_Mime_Message();
array_unshift($htmlAttachmentParts, $html);
$message->setParts($htmlAttachmentParts);
$htmlMime = $htmlAttachments->getMime();
$message->setMime($htmlMime);
$html = new Zend_Mime_Part($message->generateMessage($this->EOL, false));
$html->boundary = $htmlMime->boundary();
$html->type = Zend_Mime::MULTIPART_RELATED;
$html->encoding = null;
}
$body = $boundaryLine;
if ($text) {
$text->disposition = false;
$body .= $text->getHeaders($this->EOL) . $this->EOL . $text->getContent($this->EOL) . $this->EOL . $boundaryLine;
}
$body .= $html->getHeaders($this->EOL) . $this->EOL . $html->getContent($this->EOL) . $this->EOL . $boundaryEnd;
$mp = new Zend_Mime_Part($body);
$mp->type = Zend_Mime::MULTIPART_ALTERNATIVE;
$mp->boundary = $mime->boundary();
$this->_isMultipart = true;
// Ensure first part contains text alternatives
array_unshift($this->_parts, $mp);
// Get headers
$this->_headers = $this->_mail->getHeaders();
return;
}
// If not multipart, then get the body
if (false !== ($body = $this->_mail->getBodyHtml())) {
array_unshift($this->_parts, $body);
if ($hasHtmlRelatedParts) {
$this->_mail->setType(Zend_Mime::MULTIPART_RELATED);
foreach ($htmlAttachmentParts as $part) {
$this->_parts[] = $part;
}
}
} elseif (false !== ($body = $this->_mail->getBodyText())) {
array_unshift($this->_parts, $body);
}
if (!$body) {
/**
* @see Zend_Mail_Transport_Exception
*/
require_once 'Zend/Mail/Transport/Exception.php';
throw new Zend_Mail_Transport_Exception('No body specified');
}
// Get headers
$this->_headers = $this->_mail->getHeaders();
$headers = $body->getHeadersArray($this->EOL);
foreach ($headers as $header) {
// Headers in Zend_Mime_Part are kept as arrays with two elements, a
// key and a value
$this->_headers[$header[0]] = array($header[1]);
}
}
示例9: testGetJustBodyText
public function testGetJustBodyText()
{
$text = "my body\r\n\r\n...after two newlines";
$mail = new Zend_Mail();
$mail->setBodyText($text);
$this->assertContains('my body', $mail->getBodyText(true));
$this->assertContains('after two newlines', $mail->getBodyText(true));
}
示例10: _buildBody
/**
* Generate MIME compliant message from the current configuration
*
* If both a text and HTML body are present, generates a
* multipart/alternative Zend_Mime_Part containing the headers and contents
* of each. Otherwise, uses whichever of the text or HTML parts present.
*
* The content part is then prepended to the list of Zend_Mime_Parts for
* this message.
*
* @return void
*/
protected function _buildBody()
{
////////////////////////////////////////////////////////////////////////
// //
// ALPHAFIELDS 2012-11-03: ADDED PGP/MIME ENCRYPTION //
// USING lib/openpgp/opepgplib.php //
// AS THE Subject-header is hidden and contains a hash only in a //
// pgp/mime encrypted message subject-header extract the original //
// subject and prepend it below into the text & html parts //
// //
////////////////////////////////////////////////////////////////////////
// get from globals (set in tiki-setup.php)
global $openpgplib;
$ret = $openpgplib->getPrependOriginalSubject($this->_mail);
$prepend_to_text = $ret[0];
$prepend_to_html = $ret[1];
////////////////////////////////////////////////////////////////////////
// //
// ALPHAFIELDS 2012-11-03: ..END ADD PGP/MIME ENCRYPTION PREPARATION //
// USING lib/openpgp/opepgplib.php //
// //
////////////////////////////////////////////////////////////////////////
if (($text = $this->_mail->getBodyText()) && ($html = $this->_mail->getBodyHtml())) {
// Generate unique boundary for multipart/alternative
$mime = new Zend_Mime(null);
$boundaryLine = $mime->boundaryLine($this->EOL);
$boundaryEnd = $mime->mimeEnd($this->EOL);
$text->disposition = false;
$html->disposition = false;
$body = $boundaryLine . $text->getHeaders($this->EOL) . $this->EOL . $prepend_to_text . $text->getContent($this->EOL) . $this->EOL . $boundaryLine . $html->getHeaders($this->EOL) . $this->EOL . $prepend_to_html . $html->getContent($this->EOL) . $this->EOL . $boundaryEnd;
$mp = new Zend_Mime_Part($body);
$mp->type = Zend_Mime::MULTIPART_ALTERNATIVE;
$mp->boundary = $mime->boundary();
$this->_isMultipart = true;
// Ensure first part contains text alternatives
array_unshift($this->_parts, $mp);
// Get headers
$this->_headers = $this->_mail->getHeaders();
return;
}
// If not multipart, then get the body
if (false !== ($body = $this->_mail->getBodyHtml())) {
///////////////////////////////////////////////////////////////
// ALPHAFIELDS 2012-11-03: ADDED PGP/MIME ENCRYPTION
// USING lib/openpgp/opepgplib.php
// PREPEND ORIG HEADER
$body = $prepend_to_html . $body;
// ..END ADD
///////////////////////////////////////////////////////////////
array_unshift($this->_parts, $body);
} elseif (false !== ($body = $this->_mail->getBodyText())) {
///////////////////////////////////////////////////////////////
// ALPHAFIELDS 2012-11-03: ADDED PGP/MIME ENCRYPTION
// USING lib/openpgp/opepgplib.php
// PREPEND ORIG HEADER
$body = $prepend_to_text . $body;
// ..END ADD
///////////////////////////////////////////////////////////////
array_unshift($this->_parts, $body);
}
if (!$body) {
throw new Zend_Mail_Transport_Exception('No body specified');
}
// Get headers
$this->_headers = $this->_mail->getHeaders();
$headers = $body->getHeadersArray($this->EOL);
foreach ($headers as $header) {
// Headers in Zend_Mime_Part are kept as arrays with two elements, a
// key and a value
$this->_headers[$header[0]] = array($header[1]);
}
}
示例11: format
public function format(Zend_Mail $mail)
{
return sprintf("Subject: %s\nTo: %s\nText: %s\n\nHtml: %s", $mail->getSubject(), implode(', ', $mail->getRecipients()), $mail->getBodyText()->getContent(), $mail->getBodyHtml()->getContent());
}