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


PHP Swift_Message::getReplyTo方法代码示例

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


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

示例1: getReplyTo

 /**
  * Get the reply-to address(es) as an array of strings
  * @return array
  */
 public function getReplyTo()
 {
     try {
         return $this->message->getReplyTo();
     } catch (Swift_Message_MimeException $e) {
         return false;
     }
 }
开发者ID:darkcolonist,项目名称:kohana234-doctrine115,代码行数:12,代码来源:EasySwift.php

示例2: createFromSwiftMessage

 /**
  * Creates a DmSentMail from a Swift_Message
  * @param Swift_Message $message
  * @return DmSentMail
  */
 public function createFromSwiftMessage(Swift_Message $message)
 {
     $debug = $message->toString();
     if ($attachementPosition = strpos($debug, 'attachment; filename=')) {
         $debug = substr($debug, 0, $attachementPosition);
     }
     return $this->create(array('subject' => $message->getSubject(), 'body' => $message->getBody(), 'from_email' => implode(', ', array_keys((array) $message->getFrom())), 'to_email' => implode(', ', array_keys((array) $message->getTo())), 'cc_email' => implode(', ', array_keys((array) $message->getCC())), 'bcc_email' => implode(', ', array_keys((array) $message->getBCC())), 'reply_to_email' => implode(', ', array_keys((array) $message->getReplyTo())), 'sender_email' => implode(', ', array_keys((array) $message->getSender())), 'debug_string' => $debug));
 }
开发者ID:theolymp,项目名称:diem,代码行数:13,代码来源:PluginDmSentMailTable.class.php

示例3: messageToArray

 /**
  * Converts \Swift_Message into associative array
  *
  * @param array          $search   If the mailer requires tokens in another format than Mautic's, pass array of Mautic tokens to replace
  * @param array          $replace  If the mailer requires tokens in another format than Mautic's, pass array of replacement tokens
  *
  * @return array|\Swift_Message
  */
 protected function messageToArray($search = array(), $replace = array())
 {
     if (!empty($search)) {
         MailHelper::searchReplaceTokens($search, $replace, $this->message);
     }
     $from = $this->message->getFrom();
     $fromEmail = current(array_keys($from));
     $fromName = $from[$fromEmail];
     $message = array('html' => $this->message->getBody(), 'text' => MailHelper::getPlainTextFromMessage($this->message), 'subject' => $this->message->getSubject(), 'from' => array('name' => $fromName, 'email' => $fromEmail));
     // Generate the recipients
     $message['recipients'] = array('to' => array(), 'cc' => array(), 'bcc' => array());
     $to = $this->message->getTo();
     foreach ($to as $email => $name) {
         $message['recipients']['to'][$email] = array('email' => $email, 'name' => $name);
     }
     $cc = $this->message->getCc();
     if (!empty($cc)) {
         foreach ($cc as $email => $name) {
             $message['recipients']['cc'][$email] = array('email' => $email, 'name' => $name);
         }
     }
     $bcc = $this->message->getBcc();
     if (!empty($bcc)) {
         foreach ($bcc as $email => $name) {
             $message['recipients']['bcc'][$email] = array('email' => $email, 'name' => $name);
         }
     }
     $replyTo = $this->message->getReplyTo();
     if (!empty($replyTo)) {
         foreach ($replyTo as $email => $name) {
             $message['replyTo'] = array('email' => $email, 'name' => $name);
         }
     }
     $returnPath = $this->message->getReturnPath();
     if (!empty($returnPath)) {
         $message['returnPath'] = $returnPath;
     }
     // Attachments
     $children = $this->message->getChildren();
     $attachments = array();
     foreach ($children as $child) {
         if ($child instanceof \Swift_Attachment) {
             $attachments[] = array('type' => $child->getContentType(), 'name' => $child->getFilename(), 'content' => $child->getEncoder()->encodeString($child->getBody()));
         }
     }
     $message['attachments'] = $attachments;
     return $message;
 }
开发者ID:Jornve,项目名称:mautic,代码行数:56,代码来源:AbstractTokenArrayTransport.php

示例4: send

 /**
  * Send a message to any number of recipients
  * @param Swift_Message The message to send.  This does not need to (and shouldn't really) have any of the recipient headers set.
  * @param mixed The recipients to send to.  Can be a string, Swift_Address or Swift_RecipientList. Note that all addresses apart from Bcc recipients will appear in the message headers
  * @param mixed The address to send the message from.  Can either be a string or an instance of Swift_Address.
  * @return int The number of successful recipients
  * @throws Swift_ConnectionException If sending fails for any reason.
  */
 public function send(Swift_Message $message, $recipients, $from)
 {
     Swift_ClassLoader::load("Swift_Message_Encoder");
     if (is_string($recipients) && preg_match("/^" . Swift_Message_Encoder::CHEAP_ADDRESS_RE . "\$/", $recipients)) {
         $recipients = new Swift_Address($recipients);
     } elseif (!$recipients instanceof Swift_AddressContainer) {
         throw new Exception("The recipients parameter must either be a valid string email address, " . "an instance of Swift_RecipientList or an instance of Swift_Address.");
     }
     if (is_string($from) && preg_match("/^" . Swift_Message_Encoder::CHEAP_ADDRESS_RE . "\$/", $from)) {
         $from = new Swift_Address($from);
     } elseif (!$from instanceof Swift_Address) {
         throw new Exception("The sender parameter must either be a valid string email address or " . "an instance of Swift_Address.");
     }
     $log = Swift_LogContainer::getLog();
     if (!$message->getEncoding() && !$this->connection->hasExtension("8BITMIME")) {
         $message->setEncoding("QP", true, true);
     }
     $list = $recipients;
     if ($recipients instanceof Swift_Address) {
         $list = new Swift_RecipientList();
         $list->addTo($recipients);
     }
     Swift_ClassLoader::load("Swift_Events_SendEvent");
     $send_event = new Swift_Events_SendEvent($message, $list, $from, 0);
     $this->notifyListeners($send_event, "BeforeSendListener");
     $to = $cc = array();
     if (!($has_from = $message->getFrom())) {
         $message->setFrom($from);
     }
     if (!($has_return_path = $message->getReturnPath())) {
         $message->setReturnPath($from->build(true));
     }
     if (!($has_reply_to = $message->getReplyTo())) {
         $message->setReplyTo($from);
     }
     if (!$has_reply_to[0]) {
         $message->setReplyTo($from->getAddress());
     }
     if (!($has_message_id = $message->getId())) {
         $message->generateId();
     }
     $this->command("MAIL FROM: " . $message->getReturnPath(true), 250);
     $failed = 0;
     $sent = 0;
     $tmp_sent = 0;
     $it = $list->getIterator("to");
     while ($it->hasNext()) {
         $it->next();
         $address = $it->getValue();
         $to[] = $address->build();
         try {
             $this->command("RCPT TO: " . $address->build(true), 250);
             $tmp_sent++;
         } catch (Swift_BadResponseException $e) {
             $failed++;
             $send_event->addFailedRecipient($address->getAddress());
             if ($log->hasLevel(Swift_Log::LOG_FAILURES)) {
                 $log->addfailedRecipient($address->getAddress());
             }
         }
     }
     $it = $list->getIterator("cc");
     while ($it->hasNext()) {
         $it->next();
         $address = $it->getValue();
         $cc[] = $address->build();
         try {
             $this->command("RCPT TO: " . $address->build(true), 250);
             $tmp_sent++;
         } catch (Swift_BadResponseException $e) {
             $failed++;
             $send_event->addFailedRecipient($address->getAddress());
             if ($log->hasLevel(Swift_Log::LOG_FAILURES)) {
                 $log->addfailedRecipient($address->getAddress());
             }
         }
     }
     if ($failed == count($to) + count($cc)) {
         $this->reset();
         $this->notifyListeners($send_event, "SendListener");
         return 0;
     }
     if (!($has_to = $message->getTo()) && !empty($to)) {
         $message->setTo($to);
     }
     if (!($has_cc = $message->getCc()) && !empty($cc)) {
         $message->setCc($cc);
     }
     $this->command("DATA", 354);
     $data = $message->build();
     while (false !== ($bytes = $data->read())) {
         $this->command($bytes, -1);
//.........这里部分代码省略.........
开发者ID:jenia0jenia,项目名称:otk,代码行数:101,代码来源:Swift.php

示例5: messageToArray

 /**
  * Converts \Swift_Message into associative array.
  *
  * @param array      $search            If the mailer requires tokens in another format than Mautic's, pass array of Mautic tokens to replace
  * @param array      $replace           If the mailer requires tokens in another format than Mautic's, pass array of replacement tokens
  * @param bool|false $binaryAttachments True to convert file attachments to binary
  *
  * @return array|\Swift_Message
  */
 protected function messageToArray($search = [], $replace = [], $binaryAttachments = false)
 {
     if (!empty($search)) {
         MailHelper::searchReplaceTokens($search, $replace, $this->message);
     }
     $from = $this->message->getFrom();
     $fromEmail = current(array_keys($from));
     $fromName = $from[$fromEmail];
     $message = ['html' => $this->message->getBody(), 'text' => MailHelper::getPlainTextFromMessage($this->message), 'subject' => $this->message->getSubject(), 'from' => ['name' => $fromName, 'email' => $fromEmail]];
     // Generate the recipients
     $message['recipients'] = ['to' => [], 'cc' => [], 'bcc' => []];
     $to = $this->message->getTo();
     foreach ($to as $email => $name) {
         $message['recipients']['to'][$email] = ['email' => $email, 'name' => $name];
     }
     $cc = $this->message->getCc();
     if (!empty($cc)) {
         foreach ($cc as $email => $name) {
             $message['recipients']['cc'][$email] = ['email' => $email, 'name' => $name];
         }
     }
     $bcc = $this->message->getBcc();
     if (!empty($bcc)) {
         foreach ($bcc as $email => $name) {
             $message['recipients']['bcc'][$email] = ['email' => $email, 'name' => $name];
         }
     }
     $replyTo = $this->message->getReplyTo();
     if (!empty($replyTo)) {
         foreach ($replyTo as $email => $name) {
             $message['replyTo'] = ['email' => $email, 'name' => $name];
         }
     }
     $returnPath = $this->message->getReturnPath();
     if (!empty($returnPath)) {
         $message['returnPath'] = $returnPath;
     }
     // Attachments
     $children = $this->message->getChildren();
     $attachments = [];
     foreach ($children as $child) {
         if ($child instanceof \Swift_Attachment) {
             $attachments[] = ['type' => $child->getContentType(), 'name' => $child->getFilename(), 'content' => $child->getEncoder()->encodeString($child->getBody())];
         }
     }
     if ($binaryAttachments) {
         // Convert attachments to binary if applicable
         $message['attachments'] = $attachments;
         $fileAttachments = $this->getAttachments();
         if (!empty($fileAttachments)) {
             foreach ($fileAttachments as $attachment) {
                 if (file_exists($attachment['filePath']) && is_readable($attachment['filePath'])) {
                     try {
                         $swiftAttachment = \Swift_Attachment::fromPath($attachment['filePath']);
                         if (!empty($attachment['fileName'])) {
                             $swiftAttachment->setFilename($attachment['fileName']);
                         }
                         if (!empty($attachment['contentType'])) {
                             $swiftAttachment->setContentType($attachment['contentType']);
                         }
                         if (!empty($attachment['inline'])) {
                             $swiftAttachment->setDisposition('inline');
                         }
                         $message['attachments'][] = ['type' => $swiftAttachment->getContentType(), 'name' => $swiftAttachment->getFilename(), 'content' => $swiftAttachment->getEncoder()->encodeString($swiftAttachment->getBody())];
                     } catch (\Exception $e) {
                         error_log($e);
                     }
                 }
             }
         }
     } else {
         $message['binary_attachments'] = $attachments;
         $message['file_attachments'] = $this->getAttachments();
     }
     $message['headers'] = [];
     $headers = $this->message->getHeaders()->getAll();
     /** @var \Swift_Mime_Header $header */
     foreach ($headers as $header) {
         if ($header->getFieldType() == \Swift_Mime_Header::TYPE_TEXT) {
             $message['headers'][$header->getFieldName()] = $header->getFieldBodyModel();
         }
     }
     return $message;
 }
开发者ID:dongilbert,项目名称:mautic,代码行数:93,代码来源:AbstractTokenArrayTransport.php

示例6: getReplyTo

 /**
  * Get the reply-to address(es) as an array of strings
  * @return array
  */
 function getReplyTo()
 {
     return $this->message->getReplyTo();
 }
开发者ID:jeffthestampede,项目名称:excelsior,代码行数:8,代码来源:EasySwift.php

示例7: logSwiftmailMessage

 /**
  * PHPWS_Email has a built-in simple logging function.  This replicates
  * the functionality of that function for SwiftMail.
  */
 public static function logSwiftmailMessage(Swift_Message $message)
 {
     $id = 'id:' . $message->getId();
     $from = 'from:' . $message->getSender();
     $to = 'to:' . implode(',', array_keys($message->getTo()));
     // Optional fields, If the message has them, implode the arrays to simple strings.
     $cc = $message->getCc() != null ? 'cc:' . implode(',', array_keys($message->getCc())) : '';
     $bcc = $message->getBcc() != null ? 'bcc:' . implode(',', array_keys($message->getBcc())) : '';
     $replyto = $message->getReplyTo() != null ? 'reply-to:' . implode(',', array_keys($message->getReplyTo())) : '';
     $subject = 'subject:' . $message->getSubject();
     $module = 'module:' . PHPWS_Core::getCurrentModule();
     $user = 'user:' . (Current_User::isLogged() ? Current_User::getUsername() : '');
     PHPWS_Core::log("{$id} {$module} {$user} {$subject} {$from} {$to} {$cc} {$bcc} {$replyto}", 'phpws-mail.log', 'mail');
 }
开发者ID:jlbooker,项目名称:homestead,代码行数:18,代码来源:HMS_Email.php

示例8: getReplyTo

 /**
  * Returns the reply-to address.
  *
  * @return Email
  */
 public function getReplyTo()
 {
     $replyTo = $this->message->getReplyTo();
     return new Email($replyTo);
 }
开发者ID:Webiny,项目名称:Framework,代码行数:10,代码来源:Message.php

示例9: createFromSwiftMessage

 /**
  * Creates a DmSentMail from a Swift_Message
  * @param Swift_Message $message
  * @return DmSentMail
  */
 public function createFromSwiftMessage(Swift_Message $message)
 {
     return $this->create(array('subject' => $message->getSubject(), 'body' => $message->getBody(), 'from_email' => implode(', ', array_keys((array) $message->getFrom())), 'to_email' => implode(', ', array_keys((array) $message->getTo())), 'cc_email' => implode(', ', array_keys((array) $message->getCC())), 'bcc_email' => implode(', ', array_keys((array) $message->getBCC())), 'reply_to_email' => $message->getReplyTo(), 'sender_email' => $message->getSender(), 'debug_string' => $message->toString()));
 }
开发者ID:jdart,项目名称:diem,代码行数:9,代码来源:PluginDmSentMailTable.class.php


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