php邮件密件抄送不起作用 [英] Php Mail BCC not working

查看:82
本文介绍了php邮件密件抄送不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试编辑此脚本以将密件抄送副本发送给自己:

I am trying to edit this script to send a Bcc copy to myself:

$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; ,但它不会发送电子邮件...如何修改该脚本以使其起作用?

i have tried to add this $headers .= "Bcc:email@example.com"\n"; but it does not send out the email... How do I go about modofying this script to make it work?

推荐答案

标头用 \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");  
   }  
}

这篇关于php邮件密件抄送不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆