【问题标题】:Add a CC to a mail to script将 CC 添加到邮件到脚本
【发布时间】:2013-10-04 14:49:33
【问题描述】:

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

mail("mainemail@email.com;CCemail@email.com", $subject, $message, $header);

【问题讨论】:

标签: php html


【解决方案1】:
    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=

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2023-01-20
    • 1970-01-01
    • 1970-01-01
    • 2018-01-04
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多