使用 PHP PEAR 邮件发送多个 CC 和 BCC
我有一个项目,我正在工作,我正在使用Pear的邮件。我需要使用smtp,因为我们需要能够跟踪邮件服务器中的所有内容。用户需要能够在发送基于公司的电子邮件之前登录。我们不能使用php的mail函数。
我的问题是,我无法在网上找到任何用于发送CC和BCC以及发送多个BCC的文档。使用php'mail功能非常容易。您所要做的就是将其添加到$header变量中,如下所示
$headers .= 'Cc: birthdayarchive@example.com' . "\r\n";
$headers .= 'Bcc: birthdaycheck@example.com' . "\r\n";
这是我使用PEAR的php函数的代码
function sender_mail($email,$subject,$mailmsg, $cc, $bcc){
include("Mail.php");
/* mail setup recipients, subject etc */
//DEFAULT VALUE OF FROM
$from = "noreply@addata.net";
//GET EMAIL OF USER
$result = mysql_query("SELECT email, email_pass FROM u_perinfo WHERE user_id = '$_SESSION[uid]'")
or die("There was an error when grabbing your email information");
if(mysql_num_rows($result) > 0){
$row = mysql_fetch_array($result);
if($row[0] != ''){
$from = $row[0];
}
$email_pass = $row[1];
}
$recipients = "$email";
$headers["From"] = "$from";
$headers["To"] = "$email";
$headers["Subject"] = $subject;
$headers["Cc"] = "$cc"; //Line added by Me to see if it works
$headers["Bcc"] = "$bcc"; //Line added by Me to see if it works
//$mailmsg = "Welcome to Addatareference.com! \r\n\r\nBelow is your unique login information. \r\n\r\n(Please do not share your login information.)$accountinfo";
/* SMTP server name, port, user/passwd */
$smtpinfo["host"] = "smtp.emailsrvr.com";
$smtpinfo["port"] = "25";
$smtpinfo["auth"] = true;
$smtpinfo["username"] = "$from";
$smtpinfo["password"] = "$email_pass";
/* Create the mail object using the Mail::factory method */
$mail_object =& Mail::factory("smtp", $smtpinfo);
/* Ok send mail */
$mail_object->send($recipients, $headers, $mailmsg);
}
我一直在努力寻找解决这个问题的方法,而没有真正的信息回来。如果有人能帮助我解决这个问题,我将不胜感激。