Php is not sending mail to ''Bcc'' and "


Php is not sending mail to ''Bcc'' and "to"

我的查询表单工作正常,但现在它只发送电子邮件给Cc电子邮件id

<?php
if($_REQUEST["name"])
 {
?>
<?php
$email;$comment;$captcha;
    if(isset($_POST['email'])){
      $email=$_POST['email'];
    }if(isset($_POST['comment'])){
      $email=$_POST['comment'];
    }if(isset($_POST['g-recaptcha-response'])){
      $captcha=$_POST['g-recaptcha-response'];
    }
    if(!$captcha){
      echo '<h2>Please check the the captcha form.</h2>';
      exit;
    }
    $response=file_get_contents("https://www.google.com/recaptcha/api/siteverify?secret=xxx&response=".$captcha."&remoteip=".$_SERVER['REMOTE_ADDR']);
    if($response.success==false)
?>

<?php
if($_REQUEST["emailid"] || $_REQUEST["phone"])
{
$to = "mail2@123.in";
 $subject = "Enquiry on tour Packages from ".$_REQUEST["name"];
 $message = "
 <html>
 <head>
   <title>Enquiry from ".$_REQUEST["name"]."</title>
  </head>
    <body>
       <p><b>Dear Sir</b>,<br> I am interested in  Tour Packages, my details are given below</p>
<table>
 <tr>
  <td><b>Full Name :  </b>".$_REQUEST["name"]."</td></tr>
     <tr><td><b>Email ID :   </b>".$_REQUEST["emailid"]."</td></tr>
      <tr><td><b>Package :   </b>".$_REQUEST["type"]."</td></tr>
  <tr><td><b>Date of Arrival:   </b>".$_REQUEST["date"]."</td></tr>
    <tr><td><b>Country:   </b>".$_REQUEST["country"]."</td></tr>
   <tr><td><b>Phone:   </b>".$_REQUEST["phone"]."</td></tr>
    <tr><td><b>Adults Number :   </b>".$_REQUEST["adults"]."</td></tr>
    <tr><td><b>Kids Number:   </b>".$_REQUEST["kids"]."</td></tr>
    <tr><td><b>Comments:   </b>".$_REQUEST["comments"]."</td></tr>
   </table>
    <br>
    <p>Regards, <br> ".$_REQUEST["name"]."</p>
    </body>
     </html>
     ";
      // Always set content-type when sending HTML email
      $headers = "MIME-Version: 1.0" . "'r'n";
       $headers .= "Content-type:text/html;charset=iso-8859-1" . "'r'n";
      // More headers
        $headers .= 'From: mail@123.com' . "'r'n";
        $headers .= 'Reply-To: no_reply@123.com' . "'r'n";
        $headers .= 'Cc: mail1@123.com' . "'r'n";
        $headers .= 'Bcc: mail@123.com' . "'r'n";
          if (mail($to,$subject,$message,$headers))
        {
         echo " Hi ".$_REQUEST["name"]." ! Your enquiry Sent Successfully";
           ?>
            <?php ; ?>
            <?php
            } else
               {
         echo "Mailer Error: Contact Reservation Department, call  Tel: +91 484 2381122, 4144144 or mail to emailid@xxx.com";
        }
       }
       }
         ?>

我希望这对你有帮助,

:下载这个库(https://github.com/ivantcholakov/codeigniter-phpmailer—OR—https://travis-ci.org/PHPMailer/PHPMailer)

第二:

复制-粘贴库到你的控制器

下面是如何在代码中使用它,

      private function send_forgot_password($data) {
        require(APPPATH.'controllers/mail-master/PHPMailerAutoload.php');
        // $email_encode=urlencode($data['email']);
        $mail = new PHPMailer;
        // $mail->SMTPDebug = 3;
        $mail->isSMTP();
        $mail->Host       = 'mail-host.com';
        $mail->SMTPAuth   = true;
        $mail->Username   = 'testing-alert@mail-host.com';
        $mail->Password   = '12345';
        $mail->SMTPSecure = 'tls';
        $mail->Port       = 25;
        // Email body
        $mail->From     = 'testing-alert@mail-host.com';
        $mail->FromName = 'Name';
        $mail->addAddress($data['email']);
        $mail->isHTML(true);
        $mail->Subject = 'Forgot Password';
        $mail->Body    = ' email body ';
        $mail->send(); 
}