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


PHP Swift_Message::addCc方法代码示例

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


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

示例1: testSend

 public function testSend()
 {
     $message = new Swift_Message();
     $message->setFrom('johnny5@example.com', 'Johnny #5');
     $message->setSubject('Is alive!');
     $message->addTo('you@example.com', 'A. Friend');
     $message->addTo('you+two@example.com');
     $message->addCc('another+1@example.com');
     $message->addCc('another+2@example.com', 'Extra 2');
     $message->addBcc('another+3@example.com');
     $message->addBcc('another+4@example.com', 'Extra 4');
     $message->addPart('<q>Help me Rhonda</q>', 'text/html');
     $message->addPart('Doo-wah-ditty.', 'text/plain');
     $attachment = Swift_Attachment::newInstance('This is the plain text attachment.', 'hello.txt', 'text/plain');
     $attachment2 = Swift_Attachment::newInstance('This is the plain text attachment.', 'hello.txt', 'text/plain');
     $attachment2->setDisposition('inline');
     $message->attach($attachment);
     $message->attach($attachment2);
     $message->setPriority(1);
     $headers = $message->getHeaders();
     $headers->addTextHeader('X-PM-Tag', 'movie-quotes');
     $messageId = $headers->get('Message-ID')->getId();
     $transport = new PostmarkTransportStub('TESTING_SERVER');
     $client = $this->getMock('GuzzleHttp\\Client', array('request'));
     $transport->setHttpClient($client);
     $o = PHP_OS;
     $v = phpversion();
     $client->expects($this->once())->method('request')->with($this->equalTo('POST'), $this->equalTo('https://api.postmarkapp.com/email'), $this->equalTo(['headers' => ['X-Postmark-Server-Token' => 'TESTING_SERVER', 'User-Agent' => "swiftmailer-postmark (PHP Version: {$v}, OS: {$o})", 'Content-Type' => 'application/json'], 'json' => ['From' => '"Johnny #5" <johnny5@example.com>', 'To' => '"A. Friend" <you@example.com>,you+two@example.com', 'Cc' => 'another+1@example.com,"Extra 2" <another+2@example.com>', 'Bcc' => 'another+3@example.com,"Extra 4" <another+4@example.com>', 'Subject' => 'Is alive!', 'Tag' => 'movie-quotes', 'TextBody' => 'Doo-wah-ditty.', 'HtmlBody' => '<q>Help me Rhonda</q>', 'Headers' => [['Name' => 'Message-ID', 'Value' => '<' . $messageId . '>'], ['Name' => 'X-PM-KeepID', 'Value' => 'true'], ['Name' => 'X-Priority', 'Value' => '1 (Highest)']], 'Attachments' => [['ContentType' => 'text/plain', 'Content' => 'VGhpcyBpcyB0aGUgcGxhaW4gdGV4dCBhdHRhY2htZW50Lg==', 'Name' => 'hello.txt'], ['ContentType' => 'text/plain', 'Content' => 'VGhpcyBpcyB0aGUgcGxhaW4gdGV4dCBhdHRhY2htZW50Lg==', 'Name' => 'hello.txt', 'ContentID' => 'cid:' . $attachment2->getId()]]]]));
     $transport->send($message);
 }
开发者ID:wildbit,项目名称:swiftmailer-postmark,代码行数:30,代码来源:TransportTest.php

示例2: fromWrappedMessage

 /**
  * @inheritDoc
  */
 public static function fromWrappedMessage(MailWrappedMessage $wrappedMessage = null, $transport = null)
 {
     if (!$wrappedMessage instanceof MailWrappedMessage) {
         throw new MailWrapperSetupException('Not MailWrappedMessage');
     }
     $message = new \Swift_Message();
     foreach ($wrappedMessage->getToRecipients() as $address) {
         $message->addTo($address);
     }
     foreach ($wrappedMessage->getCcRecipients() as $address) {
         $message->addCc($address);
     }
     foreach ($wrappedMessage->getBccRecipients() as $address) {
         $message->addBcc($address);
     }
     $message->setReplyTo($wrappedMessage->getReplyTo());
     $message->setFrom($wrappedMessage->getFrom());
     $message->setSubject($wrappedMessage->getSubject());
     if ($wrappedMessage->getContentText()) {
         $message->setBody($wrappedMessage->getContentText());
     }
     if ($wrappedMessage->getContentHtml()) {
         $message->setBody($wrappedMessage->getContentHtml(), 'text/html');
     }
     return $message;
 }
开发者ID:BespokeSupport,项目名称:MailWrapper,代码行数:29,代码来源:MessageTransformerSwift.php

示例3: addMailAddresses

 /**
  * Add email addresses
  *
  * @param Swift_Message $mail
  * @param string $addresses
  * @param string $field Address field, can be 'to','cc','bcc'
  */
 public function addMailAddresses(&$mail, $addresses, $field = 'to')
 {
     if (trim($addresses) == '') {
         return;
     }
     $addrs = explode(';', $addresses);
     foreach ($addrs as $addr) {
         //Reformat standar email "name" <email> to name,email
         $addr = str_replace('" <', '"<', $addr);
         $addr = str_replace('"<', ',', $addr);
         $addr = str_replace('"', '', $addr);
         $addr = str_replace('>', '', $addr);
         //Fix address format: name,email
         if (strpos($addr, ',') === false) {
             $addr = ',' . $addr;
         }
         $tmp = explode(',', $addr);
         switch ($field) {
             case 'cc':
                 $mail->addCc($tmp[1], $tmp[0]);
                 break;
             case 'bcc':
                 $mail->addBcc($tmp[1], $tmp[0]);
                 break;
             default:
                 $mail->addTo($tmp[1], $tmp[0]);
                 break;
         }
     }
 }
开发者ID:hung5s,项目名称:yap,代码行数:37,代码来源:Email.php

示例4: addCc

 /**
  * {@inheritdoc}
  *
  * @return $this|self
  */
 public function addCc($address, $name = null) : self
 {
     return $this->message->addCc($address, $name);
 }
开发者ID:cawaphp,项目名称:email,代码行数:9,代码来源:Message.php

示例5: addCc

 public function addCc(Email $email)
 {
     $this->message->addCc($email->email, $email->name);
     return $this;
 }
开发者ID:Webiny,项目名称:Framework,代码行数:5,代码来源:Message.php

示例6: setupMessageHeaders

 /**
  * @param \Swift_Message $instance
  * @param  array  $from              From addresses. An array of (email-address => name)
  * @param  array  $to                To addresses. An array of (email-address => name)
  * @param  array  $cc                Cc addresses. An array of (email-address => name) [optional]
  * @param  array  $bcc               Bcc addresses. An array of (email-address => name) [optional]
  * @param  array  $replyTo           Reply to addresses. An array of (email-address => name) [optional]
  */
 protected function setupMessageHeaders($instance, $from, $to, $cc = [], $bcc = [], $replyTo = [])
 {
     // Add from addresses
     foreach ($from as $address => $name) {
         $instance->addFrom($address, $name);
     }
     // Add to addresses
     foreach ($to as $address => $name) {
         $instance->addTo($address, $name);
     }
     // Add cc addresses
     foreach ($cc as $address => $name) {
         $instance->addCc($address, $name);
     }
     // Add bcc addresses
     foreach ($bcc as $address => $name) {
         $instance->addBcc($address, $name);
     }
     // Add reply to addresses
     foreach ($replyTo as $address => $name) {
         $instance->addReplyTo($address, $name);
     }
 }
开发者ID:vigourouxjulien,项目名称:thelia,代码行数:31,代码来源:MailerFactory.php


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