当前位置: 首页>>代码示例>>PHP>>正文


PHP Message::getTo方法代码示例

本文整理汇总了PHP中Zend\Mail\Message::getTo方法的典型用法代码示例。如果您正苦于以下问题:PHP Message::getTo方法的具体用法?PHP Message::getTo怎么用?PHP Message::getTo使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Zend\Mail\Message的用法示例。


在下文中一共展示了Message::getTo方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: testToAddressListLivesInHeaders

 public function testToAddressListLivesInHeaders()
 {
     $this->message->addTo('zf-devteam@zend.com');
     $to = $this->message->getTo();
     $headers = $this->message->getHeaders();
     $this->assertInstanceOf('Zend\\Mail\\Headers', $headers);
     $this->assertTrue($headers->has('to'));
     $header = $headers->get('to');
     $this->assertSame($header->getAddressList(), $to);
 }
开发者ID:nuklehed,项目名称:zf2,代码行数:10,代码来源:MessageTest.php

示例2: prepareRecipients

 /**
  * Prepare array of email address recipients
  *
  * @param  Message $message
  * @return array
  */
 protected function prepareRecipients(Message $message)
 {
     $recipients = array();
     foreach ($message->getTo() as $address) {
         $recipients[] = $address->getEmail();
     }
     foreach ($message->getCc() as $address) {
         $recipients[] = $address->getEmail();
     }
     foreach ($message->getBcc() as $address) {
         $recipients[] = $address->getEmail();
     }
     $recipients = array_unique($recipients);
     return $recipients;
 }
开发者ID:Baft,项目名称:Zend-Form,代码行数:21,代码来源:Smtp.php

示例3: prepareRecipients

 /**
  * Prepare array of email address recipients
  *
  * @param  Message $message
  * @return array
  */
 protected function prepareRecipients(Message $message)
 {
     if ($this->getEnvelope() && $this->getEnvelope()->getTo()) {
         return (array) $this->getEnvelope()->getTo();
     }
     $recipients = [];
     foreach ($message->getTo() as $address) {
         $recipients[] = $address->getEmail();
     }
     foreach ($message->getCc() as $address) {
         $recipients[] = $address->getEmail();
     }
     foreach ($message->getBcc() as $address) {
         $recipients[] = $address->getEmail();
     }
     $recipients = array_unique($recipients);
     return $recipients;
 }
开发者ID:ppiedaderawnet,项目名称:concrete5,代码行数:24,代码来源:Smtp.php

示例4: 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;
 }
开发者ID:andrebian,项目名称:sendgrid-transport-module,代码行数:10,代码来源:SendGridTransport.php

示例5: _assembleMailMessage

 /**
  * @param       $subject
  * @param       $html
  * @param       $plain
  * @param array $options
  * @param array $receivers
  * @param array $attachments
  *
  * @return Mail\Message
  */
 protected function _assembleMailMessage($subject, $html, $plain, array $options, array $receivers, array $attachments = [])
 {
     $config = $this->_rendererConfig;
     $message = new Mail\Message();
     $message->setEncoding('UTF-8');
     // Sender
     if (isset($options['use_default_sender']) && $options['use_default_sender'] === true) {
         $fromEmail = isset($config['mail_from_email']) ? $config['mail_from_email'] : null;
         $fromName = isset($config['mail_from_name']) ? $config['mail_from_name'] : null;
     } else {
         $fromEmail = isset($options['sender_mail']) ? $options['sender_mail'] : null;
         $fromName = isset($options['sender_name']) ? $options['sender_name'] : null;
     }
     $addressListFrom = new Mail\AddressList();
     $addressListFrom->add(new Mail\Address($fromEmail, isset($fromName) ? $fromName : null));
     $message->setFrom($addressListFrom);
     // Receiver
     $addressListTo = new Mail\AddressList();
     foreach ($receivers as $receiver) {
         $recEmail = isset($config['email_receiver_override']) ? $config['email_receiver_override'] : $receiver[0];
         $recName = isset($receiver[1]) ? $receiver[1] : null;
         $addressListTo->add(new Mail\Address($recEmail, $recName));
     }
     $message->setTo($addressListTo);
     if (isset($config['mail_bcc']) && is_array($config['mail_bcc'])) {
         foreach ($config['mail_bcc'] as $bccAddress) {
             // Avoid sending email copy to "to" AND bcc
             $found = false;
             foreach ($message->getTo() as $to) {
                 if ($to->getEmail() == $bccAddress) {
                     $found = true;
                     break;
                 }
             }
             if (!$found) {
                 $addressListBcc = new Mail\AddressList();
                 $addressListBcc->add(new Mail\Address($bccAddress));
                 $message->addBcc($addressListBcc);
             }
         }
     }
     if (isset($config['subject_prefix']) && $config['subject_prefix'] != '') {
         $subject = $config['subject_prefix'] . $subject;
     }
     $message->setSubject($subject);
     if (empty($attachments)) {
         $message->setBody($html);
         $contentType = Mail\Header\ContentType::fromString('Content-Type: text/html; charset=utf-8');
         $message->getHeaders()->addHeader($contentType);
         $contentTransferEncoding = Mail\Header\ContentTransferEncoding::fromString('Content-Transfer-Encoding: 8bit');
         $message->getHeaders()->addHeader($contentTransferEncoding);
     } else {
         $html = new Mime\Part($html);
         $html->type = Mime\Mime::TYPE_HTML;
         $html->charset = 'UTF-8';
         $html->disposition = Mime\Mime::DISPOSITION_INLINE;
         $html->encoding = Mime\Mime::ENCODING_QUOTEDPRINTABLE;
         $body = new Mime\Message();
         $body->addPart($html);
         foreach ($attachments as $attachmentData) {
             if (isset($attachmentData['file_path']) && is_readable($attachmentData['file_path'])) {
                 $attachmentData['file_data'] = file_get_contents($attachmentData['file_path']);
             }
             if (isset($attachmentData['file_data']) && !empty($attachmentData['file_data'])) {
                 $attachment = new Mime\Part($attachmentData['file_data']);
                 $attachment->type = $attachmentData['mime_type'];
                 $attachment->filename = $attachmentData['name'];
                 $attachment->disposition = Mime\Mime::DISPOSITION_ATTACHMENT;
                 $attachment->encoding = Mime\Mime::ENCODING_BASE64;
                 $body->addPart($attachment);
             }
         }
         $message->setBody($body);
     }
     return $message;
 }
开发者ID:mb-tec,项目名称:zf-email,代码行数:86,代码来源:Renderer.php

示例6: convertZFMail

 /**
  * Create `Mandrill message` from `ZF message`.
  *
  * @param ZendMessage $zfMessage
  *
  * @return Message
  */
 public static function convertZFMail(ZendMessage $zfMessage)
 {
     $mandrillMessage = new self();
     // GET HTML MIME PART
     $messageHtmlPart = $messageTextPart = null;
     $mimeParts = $zfMessage->getBody()->getParts();
     foreach ($mimeParts as $mimePart) {
         switch ($mimePart->getType()) {
             case ZendMime::TYPE_HTML:
                 $messageHtmlPart = $mimePart->getContent();
                 break;
             case ZendMime::TYPE_TEXT:
                 $messageTextPart = $mimePart->getContent();
                 break;
         }
     }
     // text part
     if ($messageTextPart !== null) {
         $mandrillMessage->text = $messageTextPart;
     }
     // html part
     if ($messageHtmlPart !== null) {
         $mandrillMessage->html = $messageHtmlPart;
     }
     // subject
     if ($zfMessage->getSubject() !== null) {
         $mandrillMessage->subject = $zfMessage->getSubject();
     }
     // from
     if ($zfMessage->getFrom()->count()) {
         $mandrillMessage->from_email = $zfMessage->getFrom()->current()->getEmail();
         $mandrillMessage->from_name = $zfMessage->getFrom()->current()->getName();
     }
     // reply-to
     if ($zfMessage->getReplyTo()->count()) {
         $mandrillMessage->headers = ['Reply-To' => $zfMessage->getReplyTo()->current()->getEmail()];
     }
     // to
     if ($zfMessage->getTo()->count()) {
         foreach ($zfMessage->getTo() as $to) {
             $mandrillMessage->addRecipient(new Recipient($to->getEmail(), null, Recipient::RECIPIENT_TYPE_TO));
         }
     }
     // cc
     if ($zfMessage->getCc()->count()) {
         foreach ($zfMessage->getCc() as $cc) {
             $mandrillMessage->addRecipient(new Recipient($cc->getEmail(), null, Recipient::RECIPIENT_TYPE_CC));
         }
     }
     // bcc
     if ($zfMessage->getBcc()->count()) {
         foreach ($zfMessage->getBcc() as $bcc) {
             $mandrillMessage->addRecipient(new Recipient($bcc->getEmail(), null, Recipient::RECIPIENT_TYPE_BCC));
         }
     }
     return $mandrillMessage;
 }
开发者ID:freax,项目名称:mandrill-zend2,代码行数:64,代码来源:Message.php

示例7: prepareAddressList

 /**
  * Prepares list of all mail recipients
  *
  * @param Message $message
  * @return array
  */
 private function prepareAddressList(Message $message)
 {
     $addressList = array();
     foreach ($message->getTo() as $address) {
         $addressList[] = $address->getEmail();
     }
     foreach ($message->getCc() as $address) {
         $addressList[] = $address->getEmail();
     }
     foreach ($message->getBcc() as $address) {
         $addressList[] = $address->getEmail();
     }
     return $addressList;
 }
开发者ID:guliano,项目名称:esco-mail,代码行数:20,代码来源:MailLogger.php


注:本文中的Zend\Mail\Message::getTo方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。