PHP 电子邮件:收件人、抄送
我有一个可以自动发送电子邮件的 PHP 脚本。我的它工作得很好,但是当我尝试添加 CC 时,它不起作用。以下是我的电子邮件代码:
$email_to = "$theData2"; // Who the email is to
$headers = "From: ".$email_from;
$ok = @mail($email_to, $email_subject, $email_message, $headers);
我已经尝试了以下方法来使 CC 正常工作,但没有任何运气。
$email_cc = "[email protected]";
$headers .= "CC: ".$email_cc;
并且也尝试过这个:
$headers .= "CC: [email protected]";
我无法将其通过电子邮件发送到:to &抄送。
任何帮助将不胜感激。谢谢!
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 = "[email protected]";
$headers .= "CC: ".$email_cc;
and also have tried this:
$headers .= "CC: [email protected]";
I can't get it to email to both the: to & cc.
Any help would be greatly appreciated. Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
您是否尝试过使用“抄送”而不是“抄送”?并且不要忘记末尾的“\n”。
Have you tried with "Cc" and not "CC" ? And do not forget the "\n" at the end.
不要直接使用 PHP 的
mail()
函数。使用包装类,例如 SwiftMailer 或 PHPMailer。它们为您提供更大的灵活性并且更安全。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.您忘记了换行符。
You forgot your newline.
尝试以
"\r\n"
结束标头条目:Try ending your header entries with
"\r\n"
: