1

我想用 CC 发送邮件。邮件发送成功,但抄送未发送。

$to = 'abc@xyz.com';
$subject = 'Order Details of Order Number:'.$orderID; 
$headers = "From: webmaster@xyz.com\r\nReply-To: webmaster@xyz.com";
$headers .= "\r\nContent-Type: multipart/alternative; boundary=\"PHP-alt-".$random_hash."\""; 
$message = "Test Message";
$headers .= 'Cc: def@xyz.com' . "\r\n";
mail($to, $subject, $message, $headers);

我将这封邮件作为 HTML 发送。

4

2 回答 2

1

添加标题如下,

$to = 'toemailaddress@testcom';
$from = 'fromemail@from.com';
$fromName = 'FromName';
$subject = "Email Subject";
$htmlContent = "<h> content of the email </h>";
$headers = "From: $fromName" . " <" . $from . ">" . "\r\n";
$headers .= "Cc: cc@cc.com ";
$semi_rand = md5(time());
$mime_boundary = "==Multipart_Boundary_x{$semi_rand}x";
//multipart boundary 
$message = "--{$mime_boundary}\n" . "Content-Type: text/html; charset=\"UTF-8\"\n" ."Content-Transfer-Encoding: 7bit\n\n" . $htmlContent . "\n\n";
$returnpath = "-f" . $from;
$message .= "--{$mime_boundary}--";
$mail = @mail($to, $subject, $message, $headers, $returnpath);
于 2020-02-28T13:46:15.760 回答
0

尝试按以下顺序添加此代码:

$headers = "From: $from_email\r\nReply-To: $from_email";
$headers .= 'Cc: test@test.com\r\n';
$headers .= 'Bcc: test@test.com\r\n';
$headers .= "Return-Path: <info@premierinspectiontn.com>\r\n";

//add boundary string and mime type specification
$headers .= "Content-Type: multipart/mixed; boundary=\"PHP-mixed-".$random_hash."\"";

资源

于 2016-03-22T10:28:54.190 回答