开发者

PHP Email: To, CC

I have a PHP script that automatically send outs an email. I have it working great, but when I try to add a CC, it doesn't work. Below is my code for the email to:

$email_to = "$theData2"; // Who the email is to 

$headers = "From: ".$email_from; 

$ok = @mail($email_to, $email_subject, $email_message, $headers);

I have tried the following to get CC to work, but I haven't had any luck.

$email_cc = "example@info.com"; 
$headers .= "CC: ".$email_cc;

and also have tried this:

$headers .= "CC: sombodyelse@noplace.com";

I can't get it to email to both the: to & cc.

Any help would be greatly appreciated. Tha开发者_运维问答nks!


You forgot your newline.

$headers .= "\r\nCc: ".$email_cc;


Try ending your header entries with "\r\n":

$headers .= 'From: <webmaster@example.com>' . "\r\n";
$headers .= 'Cc: myboss@example.com' . "\r\n";


Have you tried with "Cc" and not "CC" ? And do not forget the "\n" at the end.


Don't use PHPs mail() function directly. Use a wrapper class such as SwiftMailer or PHPMailer. They give you far more flexibility and are safer.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜