簡體   English   中英

Php Mail BCC無法正常工作

[英]Php Mail BCC not working

我正在嘗試編輯此腳本以向自己發送密件抄送副本:

$to = $your_email;
$from = "Server Xt<dml_submitbot@noemail.com>";
$subject = "User Sent Msg :: $msg";
$HTMLmessage = $message;

emailHTML($to, $from, $subject, $HTMLmessage);

function emailHTML($to, $from, $subject, $HTMLmessage){

   $semi_rand = md5(time());  
   $mime_boundary = "==Multipart_Boundary_x{$semi_rand}x";  

   $headers = "From: ".$from;      
   $headers .=
   "\nMIME-Version: 1.0\n" .  
   "Content-Type: multipart/mixed;\n" .  
   " boundary=\"{$mime_boundary}\"";  

   $content .=
   "This is a multi-part message in MIME format.\n\n" .  
   "--{$mime_boundary}\n" .  
   "Content-Type:text/html; charset=\"iso-8859-1\"\n" .  
   "Content-Transfer-Encoding: 7bit\n\n" .  
   $HTMLmessage . "\n\n";  

   $ok = @mail($to, $subject, $content, $headers);  

   if(!$ok) {    
   die("Error sending email");  
   }  
}

我試圖添加這個$headers .= "Bcc:email@example.com"\\n";但它沒有發送電子郵件...如何修改此腳本以使其工作?

\\r\\n分隔標題。

function emailHTML($to, $from, $subject, $HTMLmessage) {

   $semi_rand = md5(time());  
   $mime_boundary = "==Multipart_Boundary_x{$semi_rand}x";  

   $headers = "From: ".$from . "\r\n";   
   $headers .= "Bcc: email@example.com\r\n";   
   $headers .=
   "MIME-Version: 1.0\r\n" .  
   "Content-Type: multipart/mixed;\r\n" .  
   " boundary=\"{$mime_boundary}\"";  

   $content .=
   "This is a multi-part message in MIME format.\r\n\r\n" .  
   "--{$mime_boundary}\r\n" .  
   "Content-Type:text/html; charset=\"iso-8859-1\"\r\n" .  
   "Content-Transfer-Encoding: 7bit\r\n\r\n" .  
   $HTMLmessage . "\r\n\r\n";  

   $ok = @mail($to, $subject, $content, $headers);  

   if(!$ok) {    
   die("Error sending email");  
   }  
}

$headers .= "Bcc:email@example.com"\\n"您使用的確切語法?

如果是,那么您應該收到錯誤,因為這不是有效的PHP語法。

嘗試更改為$headers .= 'Bcc:email@example.com' . "\\r\\n"; $headers .= 'Bcc:email@example.com' . "\\r\\n";

看起來標題的順序很重要!!!

$from = "Sender Name<sender@stackoverflow.com>";
$to="receiver@stackoverflow.com";
$headers = "From: $from\r\n";
$headers .= "To: $to\r\n";
$headers .= "Return-Path: <".$to.">\r\n";
$headers .= "MIME-Version: 1.0\r\n";
$headers .= "Bcc:email@gmail.com\r\n";
$headers .= "Content-Type: text/HTML; charset=ISO-8859-1\r\n";

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM