Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/87.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 将抄送添加到邮件收件人脚本_Php_Html - Fatal编程技术网

Php 将抄送添加到邮件收件人脚本

Php 将抄送添加到邮件收件人脚本,php,html,Php,Html,我有一个发送电子邮件的表单,我想在邮件发送行中添加一封抄送电子邮件。请告诉我,我将如何需要有下面的一行来完成这项工作。谢谢 mail("mainemail@email.com;CCemail@email.com", $subject, $message, $header); 试试这个。例4。 public function SMTPClient($subject,$content,$instance) { try { $maile

我有一个发送电子邮件的表单,我想在邮件发送行中添加一封抄送电子邮件。请告诉我,我将如何需要有下面的一行来完成这项工作。谢谢

mail("mainemail@email.com;CCemail@email.com", $subject, $message, $header);
试试这个。例4。
    public function SMTPClient($subject,$content,$instance) {
            try {
                $mailer = new PHPMailer(true); 
                $mailer->IsSMTP();
                $mailer->SMTPDebug  = 1;                     
                $mailer->SMTPAuth   = def_SMTP_AUTHENTICATION;                  // enable SMTP authentication
                $mailer->SMTPSecure = def_SMTP_SECURE;                 // sets the prefix to the servier
                $mailer->Host       = def_SMTP_SERVER;                      // sets GMAIL as the SMTP server
                $mailer->Port       = def_SMTP_PORT;                   // set the SMTP port for the GMAIL server
                $mailer->Username   = def_SMTP_USERNAME;              // GMAIL username
                $mailer->Password   = def_SMTP_PASSWORD;            // GMAIL password


                $mailer->SetFrom(def_MAIL_FROM_ADDRESS, def_MAIL_FROM_NAME);

                $to = def_MAIL_TO;

                $mailer->AddAddress($to);
                $mailer->Subject    = $subject;
                $mailer->AltBody    = "To view the message, please use an HTML compatible email viewer!"; // optional, comment out and test
                $mailer->WordWrap   = 80; // set word wrap
                $mailer->AddCC('xzy@gmail.com', 'xyz');
                $mailer->AddReplyTo(def_MAIL_TO, 'abc');
                $mailer->MsgHTML($content);
                $mailer->IsHTML(true); // send as HTML

                $mailer->Send();
                $this->logger("Message has been sent Successfully","INFO",$instance);
                echo 'Message has been sent Successfully.';
            } catch (phpmailerException $e) {
                echo $e->errorMessage()`enter code here`;
            }
        }

Note:Use the mailer component from http://code.google.com/a/apache-extras.org/p/phpmailer/downloads/detail?name=PHPMailer_5.2.4.zip&can=2&q=