PHP Method phpmailer\phpmailer\ PHPMailer::addCC Code Examples

PHP phpmailer\phpmailer\PHPMailer::addCC - 3 examples found. These are the top rated real world PHP examples of method phpmailer\phpmailer\PHPMailer::addCC extracted from open source projects. You can rate examples to help us improve the quality of examples

addCC() public method

Add a "CC" address.
public addCC ( string $address, string $name = '' ) : boolean
$address string The email address to send to
$name string
return boolean true on success, false if address already used or invalid in some way
 private function addCCs()
 {
     $emailsToAdd = $this->options->getTo();
     if (!empty($emailsToAdd)) {
         foreach ($this->options->getTo() as $to) {
             $this->mailClient->addCC($to);
         }
     }
 }
Example #2
1
 /**
  *
  * Mauro Cerone
  *
  * @todo read config from file
  */
 public static function startSendOperation()
 {
     /** @var ConfigReader $conf */
     $conf = ConfigReader::getInstance();
     $mailToSend = StesiMailQuery::create()->filterByDeliveryStatus("0")->find();
     foreach ($mailToSend as $mail) {
         try {
             /** @var StesiMail $conf */
             $mailer = new PHPMailer(true);
             $mailer->isHTML(true);
             $mailer->SMTPAuth = true;
             $mailer->isSMTP();
             $mailer->Username = $conf->getUsername();
             $mailer->Password = $conf->getPassword();
             $mailer->Host = $conf->getHost();
             $mailer->Port = $conf->getPort();
             $mailer->SMTPSecure = $conf->getSmtSecure();
             $mailer->setFrom($mail->getFrom());
             $mailer->Subject = $mail->getSubject();
             $arrayA = explode(";", $mail->getA());
             $arrayCC = explode(";", $mail->getCc());
             foreach ($arrayA as $a) {
                 if (!empty($a)) {
                     $mailer->addAddress($a);
                 }
             }
             foreach ($arrayCC as $cc) {
                 if (!empty($cc)) {
                     $mailer->addCC($cc);
                 }
             }
             $mailer->msgHTML($mail->getContent());
             $mailer->send();
             $mail->setDeliveryStatus(1);
         } catch (\Exception $ex) {
             $mail->setDeliveryStatus(-1);
             $mail->setErrorMessage($ex->getMessage());
         } finally {
             $mail->save();
         }
     }
 }
Example #3
0
 /**
  * @return $this
  */
 public function addCc()
 {
     $args = func_get_args();
     isset($args[1]) ? $this->mail->addCC($args[0], $args[1]) : $this->mail->addCC($args[0]);
     return $this;
 }