私は PHP を初めて使用し、PHP でオンライン注文 Web サイトを試しています。「cc」を使用して確認メールを送信しようとしたときに問題が発生しました。
注文が処理されるたびに、注文は常に指定された「CC」アドレスに送信されますが、「TO」には送信されません。ほとんどの場合、私のコードのエラーが原因です。
受信した確認メールでは、以下に示すように、送信者セクションのみが表示され、「送信先」セクションは空です。
From: Business@business.co.uk
To: *This space is empty*
CC: orders@business.co.uk
誰かが私が間違っている場所を指摘するのを助けることができますか? 以下のコードを添付しました。
//Code to retreive customer email
$query = "SELECT od_email
FROM tbl_order";
$result = mysql_query($query) or die(mysql_error());
$data = mysql_fetch_assoc($result);
//THIS IS THE EMAIL SENT TO THE CUSTOMER and the restaurant
//define the receiver of the email
$_SESSION['od_email'] = $data['od_email'];
$sendto = $_SESSION['od_email'];
//define the subject of the email
$subject = 'Order Confirmation | Ref No for Order: '. $_SESSION['orderId']; //this session function works properly
//define the message to be sent. Each line should be separated with \n
$message = 'test';
//Who the message is from
$from = "business@business.co.uk";
$cc = "orders@business.co.uk";
//define the headers we want passed. Note that they are separated with \r\n
$headers = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
$headers .= "From:" . $from . "\r\n";
//bcc header going to the restaurant
$headers .= "cc:" . $cc . "\r\n";
//send the email
$mail_sent = @mail( $sendto, $subject, $message, $headers );
unset($_SESSION['od_email']);
表示するために必要なものは次のとおりです。
From: **business@business.co.uk**
To: **$_SESSION['od_email'];**
CC: **orders@business.co.uk**
与えられた助けを前もって感謝します