$ Bcc不是为我发送电子邮件?

时间:2018-06-04 21:11:27

标签: php html email

我正在尝试发送电子邮件到几个不同的地址2从数据表中提取(到:和Bcc)其他地方是CC所有工作但BCC地址。我可以将地址交换到任何一个数据表地址,它会发送到我所在的那里,所以数据很好,但BCC不适合我。

这是我的代码,我从数据中提取BCC地址,但它不发送BCC地址。我已经尝试了几件事来弥补这一切无济于事!

// fetch contestant email from 'contestants' table...
$sql = $mysqli->query("select * FROM contestants where 
id='".$_SESSION['contestantId']."'");
$row = $sql->fetch_assoc();
$name = $row['name'];

//fetch event details from 'events' table...
$sql1 = $mysqli->query("select * FROM events where 
id='".$_SESSION['event_id']."'");
$row1 = $sql1->fetch_assoc();

//fetch club details from 'clubs' table...
// fetch contestant email from 'contestants' table...
$sql2 = $mysqli->query("select * FROM clubs where 
id='".$_SESSION['clubId']."'");
$row2 = $sql2->fetch_assoc();

// fetch club admin email from 'clubs' table...
$sql3 = $mysqli->query("select * FROM clubs where 
id='".$_SESSION['clubId']."'");
$row3 = $sql3->fetch_assoc();



// send mail to contestant and CC RCBearings@aol.com...

 $to        = $row3['admin_email_address'];
 $Bcc       = $row['email'];        


 $from      = 'support@racemastersevents.com';

 // To send HTML mail, the Content-type header must be set

 $headers  = 'MIME-Version: 1.0' . "\r\n";
 $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";


 // Create email headers
 $headers .= 'Bcc: $Bcc\r\n';
 $headers .= 'Cc: rbearings@ao.com' . "\r\n";
 $headers .= 'From: '.$from."\r\n".

    'Reply-To: '.$from."\r\n" .

    'X-Mailer: PHP/' . phpversion();



 // Compose a simple HTML email message

 $subject   = 'RaCEMastersEvents.com - Incomplete Order! (CAN)';

$message = '<html><body>';
$message .= '<h3><font color="red">RaCE</font>MastersEvents.com</h3>';
$message .= 'We are Up All Night Long, Assuring your Event gets Maximum 
Exposure!';
$message .= '<hr>';

$message .= '<h3 style="color:black;">'.$name.',</h3>';


$message .= '<p font-size:12px;">Has an incomplete Entry for your Event:<br><b> '.$row1['list_title'].'.</b><br> No Handshake between Paypal and RaCEMasters was received! To have completed this order a Paypal payment must have been made and a Click on the "Return To Merchant" button from Paypal was needed. <br><br>
Please check your Paypal Account for this payment and if received please Mark them Paid from the "Incomplete Orders link" on the "Current Entries" page.<br> If you did not receive this payment please contact <b>'.$name.'</b>, to see if he/she wishes to Pay and Complete this Entry or Cancel. If they Cancel simply "Delete the Incomplete Order!!<br>For assitance contact RCBearings@aol.com. </p>';

$message .= '</body></html>';

// Sending email

 if(mail($to, $subject, $message, $headers)){

    // echo 'Your mail has been sent successfully.';

}
/*  else{

    echo 'Unable to send email. Please try again.';

} */ 

?>

1 个答案:

答案 0 :(得分:0)

您需要双引号来解析变量以及\ r \ n。改变

 $headers .= 'Bcc: $Bcc\r\n';

$headers .= "Bcc: $Bcc\r\n";