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


PHP Message::addReplyTo方法代码示例

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


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

示例1: testCanSetReplyToListFromAddressList

 public function testCanSetReplyToListFromAddressList()
 {
     $list = new AddressList();
     $list->add('zf-devteam@zend.com');
     $this->message->addReplyTo('fw-announce@lists.zend.com');
     $this->message->setReplyTo($list);
     $replyTo = $this->message->getReplyTo();
     $this->assertEquals(1, count($replyTo));
     $this->assertFalse($replyTo->has('fw-announce@lists.zend.com'));
     $this->assertTrue($replyTo->has('zf-devteam@zend.com'));
 }
开发者ID:nuklehed,项目名称:zf2,代码行数:11,代码来源:MessageTest.php

示例2: send

 public function send($data = array(), $viewModel)
 {
     if ($viewModel instanceof ModelInterface) {
         $body = $this->renderModel($viewModel);
     } elseif (is_string($viewModel)) {
         $body = $this->renderText($viewModel);
     } else {
         throw new \Exception('Invalid viewModel for mail body');
     }
     $text = new MimePart('');
     $text->type = "text/plain";
     $html = new MimePart($body);
     $html->type = "text/html";
     $body_html = new MimeMessage();
     $body_html->setParts(array($text, $html));
     $mail = new Mail\Message();
     $mail->setEncoding("UTF-8");
     $mail->setBody($body_html);
     $mail->setFrom($this->_from_mail, $this->_from_name);
     $mail->addTo($data['to']);
     if (isset($data['cc'])) {
         $mail->addCc($data['cc']);
     }
     if (isset($data['bcc'])) {
         $mail->addBcc($data['bcc']);
     }
     if (isset($data['replyTo'])) {
         $mail->addReplyTo($data['replyTo'], $data['replyNameTo']);
     } else {
         $mail->addReplyTo($this->_from_mail, $this->_from_name);
     }
     if (isset($data['dkimSign'])) {
         $signer = $this->getController()->getServiceLocator()->get('DkimSigner');
         $signer->signMessage($mail);
     }
     $mail->setSubject($data['subject']);
     return $this->_transport->send($mail);
 }
开发者ID:renta,项目名称:EmailZF2,代码行数:38,代码来源:Mailer.php

示例3: run

 public function run()
 {
     $config = Config::get('xmailer.imap');
     $mail = new StorageImap(array('host' => $config['host'], 'user' => $config['user'], 'password' => $config['password']));
     //$mail = new StorageImap(Config::get('xmailer.imap'));
     if ($mail->countMessages() > 0) {
         $message = $mail->getMessage(1);
         if ($message->getHeaders()->get("from") != null) {
             $from = $message->getHeaders()->get("from")->toString();
         } else {
             $from = "";
         }
         if ($message->getHeaders()->get("to") != null) {
             $to = $message->getHeaders()->get("to")->toString();
         } else {
             $to = "";
         }
         preg_match("/[\\w._%+-]+@[\\w.-]+.[\\w]{2,}/", $from, $fromEmails);
         preg_match("/[\\w._%+-]+@[\\w.-]+.[\\w]{2,}/", $to, $toEmails);
         $sendTo = $this->getEmailAdresses($toEmails);
         if ($this->isValidSender($fromEmails[0])) {
             foreach ($sendTo as $mailadress) {
                 $fwd = new Message();
                 $fwd->setBody($message->getContent());
                 $h = $message->getHeaders();
                 $h->removeHeader('From');
                 $h->removeHeader('To');
                 $h->removeHeader('Reply-To');
                 $fwd->setHeaders($h);
                 $fwd->addFrom($mailadress['from']);
                 $fwd->addTo($mailadress['to']);
                 if (Config::get('xmailer.replyto')) {
                     $fwd->addReplyTo($fromEmails[0]);
                 }
                 $transport = new SendmailTransport();
                 $transport->send($fwd);
             }
             $mail->moveMessage(1, "INBOX.Sent");
         } else {
             $mail->moveMessage(1, "INBOX.Spam");
         }
         return t("%d email sent to %d People.", 1, count($sendTo));
     }
     return t("No emails sent.");
 }
开发者ID:CVJM-Forchheim,项目名称:xmailer,代码行数:45,代码来源:process_xmailer.php

示例4: setShadowRecipients

 /**
  * Set the BCC and CC recipients to the email (they are the same for every email).
  *
  * @return Message
  */
 public function setShadowRecipients()
 {
     //Cc recipients
     foreach ($this->email->getCc() as $emailAddress => $contact) {
         if ($contact instanceof Contact) {
             $this->message->addCc($contact->getEmail(), $contact);
         } else {
             $this->message->addCc($emailAddress, $contact);
         }
     }
     //Bcc recipients
     foreach ($this->email->getBcc() as $emailAddress => $contact) {
         if ($contact instanceof Contact) {
             $this->message->addBcc($contact->getEmail(), $contact);
         } else {
             $this->message->addBcc($emailAddress, $contact);
         }
     }
     if (!is_null($this->email->getReplyTo())) {
         $this->message->addReplyTo($this->email->getReplyTo(), $this->email->getReplyToName());
     }
 }
开发者ID:debranova,项目名称:general,代码行数:27,代码来源:EmailService.php

示例5: eventsAction

 public function eventsAction()
 {
     $id = $this->params()->fromRoute('id');
     $em = $this->getServiceLocator()->get('doctrine.entitymanager.orm_default');
     $calendar = $em->getRepository(Calendar::class)->find($id);
     if ($calendar && $this->getRequest()->isPost()) {
         try {
             $data = Json::decode($this->getRequest()->getContent(), Json::TYPE_ARRAY);
             if (!isset($data['action'])) {
                 return new ApiProblemResponse(new ApiProblem(404, 'Not Found Action'));
             }
             switch ($data['action']) {
                 case 'save':
                     $calendarEvent = new CalendarEvent();
                     $calendarEvent->setStartAt(new \DateTime($data['data']['startAt']))->setEndAt(new \DateTime($data['data']['endAt']))->setEmail($data['data']['email'])->setName($data['data']['name'])->setNotes($data['data']['notes'])->setCalendar($calendar);
                     $em->persist($calendarEvent);
                     $em->flush();
                     try {
                         $date = new \DateTime($data['data']['startAt']);
                         $mail = new Mail\Message();
                         $mail->setBody($calendar->getUser()->getDisplayName() . ' will be ready start conversation at ' . $date->format("m/d/Y H:i"));
                         $mail->setFrom('calendar@opsway.support', 'Calendar OpsDesk');
                         $mail->addTo($data['data']['email'], $data['data']['name']);
                         $mail->setSubject('You created meet with ' . $calendar->getUser()->getDisplayName());
                         $mail->addReplyTo($calendar->getUser()->getEmail());
                         $transport = new Mail\Transport\Sendmail();
                         $transport->send($mail);
                         $mail = new Mail\Message();
                         $mail->setBody($data['data']['name'] . ' will be ready start conversation at ' . $date->format("m/d/Y H:i"));
                         $mail->setFrom('calendar@opsway.support', 'Calendar OpsDesk');
                         $mail->addTo($calendar->getUser()->getEmail(), $data['data']['name']);
                         $mail->setSubject('New booking with ' . $data['data']['name']);
                         $mail->addReplyTo($data['data']['email']);
                         $transport = new Mail\Transport\Sendmail();
                         $transport->send($mail);
                     } catch (Exception $e) {
                     }
                     break;
                 case 'list':
                     $hydrator = new DoctrineObject($em, true);
                     $expr = Criteria::expr();
                     $criteria = Criteria::create();
                     $criteria->where($expr->andX($expr->gte('startAt', new \DateTime($data['startAt'])), $expr->lte('endAt', new \DateTime($data['endAt']))));
                     return new JsonModel(array_map(function ($event) use($hydrator) {
                         return $hydrator->extract($event);
                     }, $calendar->getEventsCollection()->matching($criteria)->getValues()));
                     break;
                 default:
                     return new ApiProblemResponse(new ApiProblem(404, 'Not Found Action'));
             }
         } catch (Exception $e) {
             return new ApiProblemResponse(new ApiProblem(503, $e->getMessage()));
         }
     }
     return new JsonModel([]);
 }
开发者ID:opsway,项目名称:tocat-opsdesk-platform,代码行数:56,代码来源:CalendarController.php

示例6: prepare

 /**
  * Prepare email to send.
  */
 private function prepare($email)
 {
     //Template Variables
     $templateVars = $this->config["template_vars"];
     $templateVars = array_merge($templateVars, $email->toArray());
     //If not layout, use default
     if (!$email->getLayoutName()) {
         $email->setLayoutName($this->config["defaults"]["layout_name"]);
     }
     //If not recipient, send to admin
     if (count($email->getTo()) == 0) {
         $email->addTo($this->config["emails"]["admin"]);
     }
     //If not sender, use default
     if (!$email->getFrom()) {
         $email->setFrom($this->config["defaults"]["from_email"]);
         $email->setFromName($this->config["defaults"]["from_name"]);
     }
     //Render system
     $renderer = new PhpRenderer();
     $resolver = new AggregateResolver();
     $stack = new TemplatePathStack();
     foreach ($this->config["template_path_stack"] as $path) {
         $stack->addPath($path);
     }
     $resolver->attach($stack);
     $renderer->setResolver($resolver);
     // Subject
     if (!$email->getSubject()) {
         $subjectView = $this->createView($templateVars, "subject", $email->getTemplateName());
         try {
             $email->setSubject($renderer->render($subjectView));
         } catch (\Exception $e) {
             $email->setSubject(null);
         }
     }
     // Text Content
     if (!$email->getTextContent()) {
         $textView = $this->createView($templateVars, "txt", $email->getTemplateName());
         $layoutTextView = new ViewModel($templateVars);
         $layoutTextView->setTemplate("/layout/txt/" . $email->getLayoutName());
         try {
             $layoutTextView->setVariable("content", $renderer->render($textView));
             $email->setTextContent($renderer->render($layoutTextView));
         } catch (\Exception $e) {
             $email->setTextContent(null);
         }
     }
     // Html Content
     if (!$email->getHtmlContent()) {
         $htmlView = $this->createView($templateVars, "html", $email->getTemplateName());
         $layoutHtmlView = new ViewModel($templateVars);
         $layoutHtmlView->setTemplate("/layout/html/" . $email->getLayoutName());
         try {
             $layoutHtmlView->setVariable("content", $renderer->render($htmlView));
             $email->setHtmlContent($renderer->render($layoutHtmlView));
         } catch (\Exception $e) {
             $email->setHtmlContent(null);
         }
     }
     //Create Zend Message
     $message = new Message();
     //From
     $message->setFrom($email->getFrom(), $email->getFromName());
     //Reply to
     if ($this->config["defaults"]["reply_to"]) {
         $message->addReplyTo($this->config["defaults"]["reply_to"], $this->config["defaults"]["reply_to_name"]);
     }
     if ($email->getReplyTo()) {
         $message->addReplyTo($email->getReplyTo(), $email->getReplyToName());
     }
     //To recipients
     foreach ($email->getTo() as $emailAddress => $user) {
         if (is_object($user)) {
             if ($user->getMailOpt()) {
                 $message->addTo($emailAddress, $user->getFullName());
             }
         } else {
             $message->addTo($emailAddress, $user);
         }
     }
     //Cc recipients
     foreach ($email->getCc() as $emailAddress => $name) {
         if (is_object($user)) {
             if ($user->getMailOpt()) {
                 $message->addCc($emailAddress, $user->getFullName());
             }
         } else {
             $message->addCc($emailAddress, $user);
         }
     }
     //Bcc recipients
     foreach ($email->getBcc() as $emailAddress => $name) {
         if (is_object($user)) {
             if ($user->getMailOpt()) {
                 $message->addBcc($emailAddress, $user->getFullName());
             }
//.........这里部分代码省略.........
开发者ID:dulumao,项目名称:big5,代码行数:101,代码来源:EmailService.php

示例7: getValid

 /**
  * @return Message
  */
 public static function getValid()
 {
     $message = new Message();
     $message->setFrom(MailWrapperTestBootstrap::$from);
     $message->addTo(MailWrapperTestBootstrap::$toAddresses[0]);
     $message->addTo(MailWrapperTestBootstrap::$toAddresses[1]);
     $message->addCC(MailWrapperTestBootstrap::$ccAddresses[0]);
     $message->addCC(MailWrapperTestBootstrap::$ccAddresses[1]);
     $message->addBCC(MailWrapperTestBootstrap::$bccAddresses[0]);
     $message->addBCC(MailWrapperTestBootstrap::$bccAddresses[1]);
     $message->addReplyTo(MailWrapperTestBootstrap::$alternate);
     $message->setSubject(MailWrapperTestBootstrap::$subject);
     $message->setBody(MailWrapperTestBootstrap::$contentText);
     return $message;
 }
开发者ID:BespokeSupport,项目名称:MailWrapper,代码行数:18,代码来源:TesterMessageZend.php

示例8: send

 public function send(Email $email, $params = array(), &$message = null, $attachmetList = [])
 {
     if (!$message) {
         $message = new Message();
     }
     $config = $this->config;
     $params = $this->params + $params;
     if ($email->get('from')) {
         $fromName = null;
         if (!empty($params['fromName'])) {
             $fromName = $params['fromName'];
         } else {
             $fromName = $config->get('outboundEmailFromName');
         }
         $message->addFrom(trim($email->get('from')), $fromName);
     } else {
         if (!empty($params['fromAddress'])) {
             $fromAddress = $params['fromAddress'];
         } else {
             if (!$config->get('outboundEmailFromAddress')) {
                 throw new Error('outboundEmailFromAddress is not specified in config.');
             }
             $fromAddress = $config->get('outboundEmailFromAddress');
         }
         if (!empty($params['fromName'])) {
             $fromName = $params['fromName'];
         } else {
             $fromName = $config->get('outboundEmailFromName');
         }
         $message->addFrom($fromAddress, $fromName);
     }
     if (!$email->get('from')) {
         $email->set('from', $fromAddress);
     }
     if (!empty($params['replyToAddress'])) {
         $replyToName = null;
         if (!empty($params['replyToName'])) {
             $replyToName = $params['replyToName'];
         }
         $message->setReplyTo($params['replyToAddress'], $replyToName);
     }
     $value = $email->get('to');
     if ($value) {
         $arr = explode(';', $value);
         if (is_array($arr)) {
             foreach ($arr as $address) {
                 $message->addTo(trim($address));
             }
         }
     }
     $value = $email->get('cc');
     if ($value) {
         $arr = explode(';', $value);
         if (is_array($arr)) {
             foreach ($arr as $address) {
                 $message->addCC(trim($address));
             }
         }
     }
     $value = $email->get('bcc');
     if ($value) {
         $arr = explode(';', $value);
         if (is_array($arr)) {
             foreach ($arr as $address) {
                 $message->addBCC(trim($address));
             }
         }
     }
     $value = $email->get('replyTo');
     if ($value) {
         $arr = explode(';', $value);
         if (is_array($arr)) {
             foreach ($arr as $address) {
                 $message->addReplyTo(trim($address));
             }
         }
     }
     $attachmentPartList = array();
     $attachmentCollection = $email->get('attachments');
     $attachmentInlineCollection = $email->getInlineAttachments();
     foreach ($attachmetList as $attachment) {
         $attachmentCollection[] = $attachment;
     }
     if (!empty($attachmentCollection)) {
         foreach ($attachmentCollection as $a) {
             $fileName = 'data/upload/' . $a->id;
             $attachment = new MimePart(file_get_contents($fileName));
             $attachment->disposition = Mime::DISPOSITION_ATTACHMENT;
             $attachment->encoding = Mime::ENCODING_BASE64;
             $attachment->filename = $a->get('name');
             if ($a->get('type')) {
                 $attachment->type = $a->get('type');
             }
             $attachmentPartList[] = $attachment;
         }
     }
     if (!empty($attachmentInlineCollection)) {
         foreach ($attachmentInlineCollection as $a) {
             $fileName = 'data/upload/' . $a->id;
             $attachment = new MimePart(file_get_contents($fileName));
//.........这里部分代码省略.........
开发者ID:chinazan,项目名称:zzcrm,代码行数:101,代码来源:Sender.php

示例9: MimePart

    if ($parameters['isHtml']) {
        $html = new MimePart($parameters['body']);
        $html->type = "text/html";
        $body = new MimeMessage();
        $body->addPart($html);
    } else {
        $body = $parameters['body'];
    }
    $mail->setBody($body);
    $logTo = "Enviando email para:";
    //Destinatarios
    foreach ($parameters['to'] as $to) {
        $logTo .= " " . $to['name'] . "<" . $to['email'] . ">";
        $mail->addTo($to['email'], $to['name']);
    }
    file_put_contents($logFile, "\t" . $logTo . "\n", FILE_APPEND);
    //Remetente
    $from = $parameters['from'];
    $mail->setFrom($from['email'], $from['name']);
    foreach ($parameters['replyTo'] as $replyTo) {
        $mail->addReplyTo($replyTo['email'], $replyTo['name']);
    }
    //Enviar
    $transport = new Sendmail();
    $transport->send($mail);
    file_put_contents($logFile, "\tOperação concluída \n", FILE_APPEND);
    return true;
} catch (\Exception $ex) {
    file_put_contents($logFile, "\t" . $ex->getMessage() . "\n", FILE_APPEND);
    return false;
}
开发者ID:CATSInformatica,项目名称:CatsSys,代码行数:31,代码来源:sendEmail.php

示例10: packData

 /**
  * pack tagged array of data to SendMessage format
  *
  *
  * @param Array $mailArray
  *
  * return array of data that will be converted to
  * send message
  *
  * @return Array
  */
 public function packData($mailArray)
 {
     $mimeMail = new Message();
     $textPart = $this->packText($mailArray['text'], $mailArray['header']['content-type']);
     unset($mailArray['header']['content-type']);
     $attachmentParts = $this->packAttachments($mailArray['link']);
     if (count($attachmentParts)) {
         $mimeMail->addPart($textPart);
         foreach ($attachmentParts as $part) {
             $mimeMail->addPart($part);
         }
     } else {
         $mimeMail->addPart($textPart);
     }
     $returnMail = new SendMessage();
     $returnMail->setBody($mimeMail);
     foreach ($mailArray['header'] as $header => $value) {
         switch ($header) {
             case 'references':
                 if (is_array($value)) {
                     $res = '';
                     foreach ($value as $reference) {
                         $res .= $reference . ' ';
                     }
                 } elseif (is_string($value)) {
                     $res = $value;
                 } else {
                     continue;
                 }
                 $headers = $returnMail->getHeaders();
                 $headers->addHeaderLine($header, $res);
                 $returnMail->setHeaders($headers);
                 break;
             case 'bcc':
                 $returnMail->addBcc($value);
                 break;
             case 'cc':
                 $returnMail->addCc($value);
                 break;
             case 'to':
                 $returnMail->addTo($value);
                 break;
             case 'from':
                 $returnMail->addFrom($value);
                 break;
             case 'reply-to':
                 $returnMail->addReplyTo($value);
                 break;
             case 'subject':
                 $returnMail->setSubject($value);
                 break;
             default:
                 $headers = $returnMail->getHeaders();
                 $headers->addHeaderLine($header, $value);
                 $returnMail->setHeaders($headers);
                 break;
         }
     }
     return $returnMail;
 }
开发者ID:modelframework,项目名称:mailservice,代码行数:71,代码来源:DefaultComposeStrategy.php


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