addCcRecipient() public method

public addCcRecipient ( string $address, array | null $variables = null ) : mixed
$address string
$variables array | null
return mixed
コード例 #1
0
ファイル: Message.php プロジェクト: bogardo/mailgun
 /**
  * Add a carbon copy to the message.
  *
  * @param string|array $address
  * @param string       $name
  * @param array        $variables
  *
  * @return \Bogardo\Mailgun\Mail\Message
  */
 public function cc($address, $name = "", array $variables = [])
 {
     if (!empty($variables)) {
         $this->variables[$address] = $variables;
     }
     $this->messageBuilder->addCcRecipient($address, ['full_name' => $name]);
     return $this;
 }
コード例 #2
0
 /**
  * @return MessageBuilder
  */
 public static function getValid()
 {
     $message = new MessageBuilder();
     $message->setFromAddress(MailWrapperTestBootstrap::$from);
     $message->addToRecipient(MailWrapperTestBootstrap::$toAddresses[0]);
     $message->addToRecipient(MailWrapperTestBootstrap::$toAddresses[1]);
     $message->addCcRecipient(MailWrapperTestBootstrap::$ccAddresses[0]);
     $message->addCcRecipient(MailWrapperTestBootstrap::$ccAddresses[1]);
     $message->addBccRecipient(MailWrapperTestBootstrap::$bccAddresses[0]);
     $message->addBccRecipient(MailWrapperTestBootstrap::$bccAddresses[1]);
     $message->setReplyToAddress(MailWrapperTestBootstrap::$alternate);
     $message->setSubject(MailWrapperTestBootstrap::$subject);
     $message->setTextBody(MailWrapperTestBootstrap::$contentText);
     $message->setHtmlBody(MailWrapperTestBootstrap::$contentHtml);
     return $message;
 }
コード例 #3
0
 /**
  * @param array $message
  *
  * @return \Mailgun\Messages\MessageBuilder
  * @throws \Mailgun\Messages\Exceptions\TooManyParameters
  */
 protected function createMailgunMessage(array $message)
 {
     $builder = new MessageBuilder();
     $builder->setFromAddress($message['from']);
     $builder->setSubject($message['subject']);
     foreach ($message['to'] as $to) {
         $builder->addToRecipient($to);
     }
     foreach ($message['cc'] as $cc) {
         $builder->addCcRecipient($cc);
     }
     foreach ($message['bcc'] as $bcc) {
         $builder->addBccRecipient($bcc);
     }
     if ($message['html']) {
         $builder->setHtmlBody($message['html']);
     }
     if ($message['text']) {
         $builder->setTextBody($message['text']);
     }
     return $builder;
 }
コード例 #4
0
 /**
  * @param MessageBuilder $builder
  * @param string $to
  * @param string $from
  * @param string $subject
  * @param string $content
  * @param string $plainContent
  * @param array $attachments
  * @param array $headers
  */
 protected function buildMessage(MessageBuilder $builder, $to, $from, $subject, $content, $plainContent, array $attachments, array $headers)
 {
     // Add base info
     $parsedFrom = $this->parseAddresses($from);
     foreach ($parsedFrom as $email => $name) {
         $builder->setFromAddress($email, ['full_name' => $name]);
     }
     $builder->setSubject($subject);
     $builder->setHtmlBody($content);
     $builder->setTextBody($plainContent);
     // Add attachments
     foreach ($attachments as $attachment) {
         $builder->addAttachment($attachment['filePath'], $attachment['remoteName']);
     }
     // Parse Cc & Bcc headers out if they're set
     $ccAddresses = isset($headers['Cc']) ? $headers['Cc'] : '';
     $bccAddresses = isset($headers['Bcc']) ? $headers['Bcc'] : '';
     // We handle these ourselves, so can remove them from the list of headers
     unset($headers['Cc']);
     unset($headers['Bcc']);
     // Add remaining custom headers
     foreach ($headers as $name => $data) {
         $builder->addCustomHeader($name, $data);
     }
     // Add recipients. This is done last as the 'BatchMessage' message builder
     // will trigger sends for every 1000 addresses
     $to = $this->parseAddresses($to);
     foreach ($to as $email => $name) {
         $builder->addToRecipient($email, ['full_name' => $name]);
     }
     $ccAddresses = $this->parseAddresses($ccAddresses);
     foreach ($ccAddresses as $email => $name) {
         $builder->addCcRecipient($email, ['full_name' => $name]);
     }
     $bccAddresses = $this->parseAddresses($bccAddresses);
     foreach ($bccAddresses as $email => $name) {
         $builder->addBccRecipient($email, ['full_name' => $name]);
     }
 }