addCC() 공개 메소드

Add a "CC" address.
public addCC ( string $address, string $name = '' ) : boolean
$address string The email address to send to
$name string
리턴 boolean true on success, false if address already used or invalid in some way
예제 #1
5
 /**
  *
  * 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();
         }
     }
 }
예제 #2
5
 /**
  * @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;
 }
 private function addCCs()
 {
     $emailsToAdd = $this->options->getTo();
     if (!empty($emailsToAdd)) {
         foreach ($this->options->getTo() as $to) {
             $this->mailClient->addCC($to);
         }
     }
 }