PHP电子邮件发送BCC [英] PHP Email sending BCC

查看:724
本文介绍了PHP电子邮件发送BCC的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我知道有一些与此相似的问题,但我无法使其正常工作。在一个名为$ emailList的变量中。
如果我将变量放在 $到部分但
我不能让它工作,我可以得到我的代码从窗体发送电子邮件与bcc。我甚至添加了一封电子邮件到 $到,这是,但它没有什么不同。



这是我的代码。

  $ to =name @ mydomain.com; 
$ subject。=。$ emailSubject。;
$ headers。='Bcc:$ emailList';
$ headers =From:no-reply@thepartyfinder.co.uk\r\\\
。 X-Mailer:php;
$ headers。=MIME-Version:1.0\r\\\
;
$ headers。=Content-Type:text / html; charset = ISO-8859-1\r\\\
;
$ message ='< html>< body>';
$ message。='从形式的信息';

if(mail($ to,$ subject,$ message,$ headers)){
$ sent =你的电子邮件已发送!
} else {
$ sent =(发送电子邮件时发生错误);
}

我已尝试过两个代码:

  $ headers。='Bcc:$ emailList'; 

  $ headers。='Bcc:'。$ emailList。'; 

这不是电子邮件没有分开,因为它们是。我知道这是因为如果我在 $ to 部分中放入 $ emailList 。我应该添加,忽略

解决方案

您有 $ headers。='...'; 其次是 $ headers ='...'; ;第二行是覆盖第一行。



只需将 $ headers。=Bcc:$ emailList\r\\\
;
内容类型行后面说,这应该是正常的。



在一边注意,通常需要 To 邮件服务器可能将您的邮件标记为垃圾邮件。

  $ headers =From:no-reply@thepartyfinder.co.uk\\ \\\\。 
X-Mailer:php\r\\\
;
$ headers。=MIME-Version:1.0\r\\\
;
$ headers。=Content-Type:text / html; charset = ISO-8859-1\r\\\
;
$ headers。=Bcc:$ emailList\r\\\
;


I know there are a few similar questions to this but I just can't get it working.

Ok, I have a list of emails grabbed from my database in a variable called $emailList. I can get my code to send an email from a form if I put the variable in the $to section but I cannot get it to work with bcc. I've even added an email to the $to incase it was that but it doesn't make a difference.

Here is my code.

$to = "name@mydomain.com";
$subject .= "".$emailSubject."";
$headers .= 'Bcc: $emailList';
$headers = "From: no-reply@thepartyfinder.co.uk\r\n" . "X-Mailer: php";
$headers .= "MIME-Version: 1.0\r\n";
$headers .= "Content-Type: text/html; charset=ISO-8859-1\r\n";
$message = '<html><body>';
$message .= 'THE MESSAGE FROM THE FORM';

if (mail($to, $subject, $message, $headers)) {
    $sent = "Your email was sent!";
} else {
    $sent = ("Error sending email.");
}

I've tried both codes:

$headers .= 'Bcc: $emailList';

and

$headers .= 'Bcc: '.$emailList.';

It's not that the emails aren't separated because they are. I know they are because it works if I put $emailList in the $to section.


I Should add, ignore the $message bits and the HTML stuff. I've not provided all of that so that is why it's missing from this code.

解决方案

You have $headers .= '...'; followed by $headers = '...';; the second line is overwriting the first.

Just put the $headers .= "Bcc: $emailList\r\n"; say after the Content-type line and it should be fine.

On a side note, the To is generally required; mail servers might mark your message as spam otherwise.

$headers  = "From: no-reply@thepartyfinder.co.uk\r\n" .
  "X-Mailer: php\r\n";
$headers .= "MIME-Version: 1.0\r\n";
$headers .= "Content-Type: text/html; charset=ISO-8859-1\r\n";
$headers .= "Bcc: $emailList\r\n";

这篇关于PHP电子邮件发送BCC的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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