setBcc() public method

Recipients set in this field will receive a 'blind-carbon-copy' of this message. In other words, they will get the message, but any other recipients of the message will have no such knowledge of their receipt of it. This method has the same synopsis as {@link setFrom()} and {@link setTo()}.
public setBcc ( mixed $addresses, string $name = null )
$addresses mixed
$name string optional
 /** Send a message to all Bcc: recipients */
 private function sendBcc(Swift_Mime_Message $message, $reversePath, array $bcc, array &$failedRecipients)
 {
     $sent = 0;
     foreach ($bcc as $forwardPath => $name) {
         $message->setBcc(array($forwardPath => $name));
         $sent += $this->doMailTransaction($message, $reversePath, array($forwardPath), $failedRecipients);
     }
     return $sent;
 }
Ejemplo n.º 2
0
 /**
  * Send the given Message to all recipients individually.
  * 
  * This differs from {@link send()} in the way headers are presented to the
  * recipient.  The only recipient in the "To:" field will be the individual
  * recipient it was sent to.
  * 
  * If an iterator is provided, recipients will be read from the iterator
  * one-by-one, otherwise recipient data will be retreived from the Message
  * object.
  * 
  * Sender information is always read from the Message object.
  * 
  * The return value is the number of recipients who were accepted for
  * delivery.
  * 
  * @param Swift_Mime_Message $message
  * @param array &$failedRecipients, optional
  * @param Swift_Mailer_RecipientIterator $it, optional
  * @return int
  * @see send()
  */
 public function batchSend(Swift_Mime_Message $message, &$failedRecipients = null, Swift_Mailer_RecipientIterator $it = null)
 {
     $failedRecipients = (array) $failedRecipients;
     $sent = 0;
     $to = $message->getTo();
     $cc = $message->getCc();
     $bcc = $message->getBcc();
     if (!empty($cc)) {
         $message->setCc(array());
     }
     if (!empty($bcc)) {
         $message->setBcc(array());
     }
     //Use an iterator if set
     if (isset($it)) {
         while ($it->hasNext()) {
             $message->setTo($it->nextRecipient());
             $sent += $this->send($message, $failedRecipients);
         }
     } else {
         foreach ($to as $address => $name) {
             $message->setTo(array($address => $name));
             $sent += $this->send($message, $failedRecipients);
         }
     }
     $message->setTo($to);
     if (!empty($cc)) {
         $message->setCc($cc);
     }
     if (!empty($bcc)) {
         $message->setBcc($bcc);
     }
     return $sent;
 }
Ejemplo n.º 3
0
 private function _restoreMessage(Swift_Mime_Message $message)
 {
     // restore original headers
     $headers = $message->getHeaders();
     if ($headers->has('X-Swift-To')) {
         $message->setTo($headers->get('X-Swift-To')->getNameAddresses());
         $headers->removeAll('X-Swift-To');
     } else {
         $message->setTo(null);
     }
     if ($headers->has('X-Swift-Cc')) {
         $message->setCc($headers->get('X-Swift-Cc')->getNameAddresses());
         $headers->removeAll('X-Swift-Cc');
     }
     if ($headers->has('X-Swift-Bcc')) {
         $message->setBcc($headers->get('X-Swift-Bcc')->getNameAddresses());
         $headers->removeAll('X-Swift-Bcc');
     }
 }