我从网站上复制了 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!");
}
?>
Ps 我在花药论坛上读到我不应该将标题放在数组中?我无法理解标题的概念。他们做什么,我应该如何组织他们?我只想要一个收件人、发件人、主题和密件抄送。
谢谢!