tags:

views:

50

answers:

1

This program is running but how to send multiple CC and BCC.

for($i = 0; $i < count($snteadd); $i++)
{
    $subjt    = $subject;
    $mess     = $message;
    $toinfo  .= $snteadd[$i];
    $headers  = "MIME-Version: 1.0 \r\n";
    $headers .= "Content-type: text/html; charset=iso-8859-1\r\n";
    $headers .= "from: <$fromemailid>\r\n";
    $headers .= "Reply-To: <$fromemailid>\r\n";  
    $hedders .= "cc : <$sendCC>\r\n" ; 
    $headers .= "Bcc :  <$sendBCC>\r\n";
    $headers .= "X-Mailer: PHP 4.x";         
    $sendbcc = $snteadd[$i] .",";
    $sendbcc .= $sendCC . ",";
    $sendbcc .= $sendBCC;             

    if($jvl != $i) 
    {
        $toinfo .= ", ";
    }

    if($snteadd[$i] != "") 
    {
        $result = mail($sendbcc, $subjt, $mess, $headers);
        if(!$result)
        {     
            $subjdis     = "Auto Response for Message Sending Failed";
            $headersdis  = "MIME-Version: 1.0\r\n";
            $headersdis .= "Content-type: text/html; charset=iso-8859-1\r\n";
            $headersdis .="Message Sending Failed\r\n";
            $headersdis .= "From: <$fromemailid> \r\n";
            $msgdis = "Message Could not be Delivered to this Mail ID ".$snteadd[$i];
            mail($fromemailid, $subjdis, $msgdis, $headersdis);   
            print "We encountered an error sending your mail <br>";
            //echo $headersdis;
        }
    }
}
+2  A: 

Just a comma-separated list of addresses should do for each field. Note that you have a number of typo's in the code in your question.

Andrew Cooper