gpt4 book ai didi

php - pear 邮件功能 bcc 不会发送

转载 作者:可可西里 更新时间:2023-11-01 00:05:54 25 4
gpt4 key购买 nike

我从网站上复制了 PEAR 邮件的代码,并输入了我的数据。有用。它发送邮件,但是,我想使用 bcc 发送给很多人并保持他们的地址匿名,它会发送给 $to 收件人,而不是 $bcc。

代码:

<?php
$message = "yay email!";
require_once("Mail.php");
$from = 'myaddress@mysite.com ';
$to = "anadress@gmail.com";
$bcc = "thepeopleimemailing@yaddayadda.com";
$subject = " test";
$body = $message;
$host = "smtp.mysite.com";
$username = "myusername";
$password = "mypassword";
$headers = array ('From' => $from,
'To' => $to,
'Cc' => $cc,
'Bcc' => $bcc,
'Subject' => $subject
);
$recipients = $to;


$smtp = Mail::factory('smtp',
array ('host' => $host,
'auth' => true,
'username' => $username,
'password' => $password,
'port' => '25'
)
);
$mail = $smtp->send($recipients, $headers, $body);
if (PEAR::isError($mail)) {
echo($mail->getMessage());
}
else {
echo("Message successfully sent!");
}
?>

附言我在另一个论坛上读到我不应该将标题放在数组中?我无法理解标题的概念。他们做什么,我应该如何组织他们?我只想要收件人、发件人、主题和密件抄送。

谢谢!

最佳答案

要详细说明 Chaky31 发送 Bcc 的答案,请使用以下内容,请注意我们没有在 header 中指定任何 Bcc 信息:

//All other variables should be self explanatory!

//The main recipient
$to = "test@test.com";

//Bcc recipients
$bcc = "bcc@test.com";

$headers = array ('From' => $from,
'To' => $to,
'Subject' => $subject);
$smtp = Mail::factory('smtp',
array ('host' => $host,
'port' => $port,
'auth' => true,
'username' => $username,
'password' => $password));

//We append the bcc addresses as comma seperated values to the send method
$mail = $smtp->send($to . "," . $bcc, $headers, $body);

关于php - pear 邮件功能 bcc 不会发送,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14557677/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com