我刚接触Phpmailer,现在要用它从noreply账户向一千多人发送批量邮件。当我把邮件发送给一两个人时,代码可以正常工作,但是当我发送给所有人(包括自己)时,邮件会被归为垃圾邮件。还有一个问题是,在邮件的详细信息中,会显示所有收件人的电子邮件地址,而我不希望这样做。
以下是代码:
//date_default_timezone_set('America/Toronto');
require_once('../class.phpmailer.php');
//include("class.smtp.php"); // optional, gets called from within class.phpmailer.php if not already loaded
$mail = new PHPMailer();
$mail->IsSMTP(); // telling the class to use SMTP
$mail->Host = "smtp1.site.com;smtp2.site.com";
$mail->SMTPAuth = true;// enable SMTP authentication
$mail->SMTPKeepAlive = true;// SMTP connection will not close after each email sent
$mail->Host = "mail.yourdomain.com"; // sets the SMTP server
$mail->Port = 26; // set the SMTP port for the server
$mail->Username = "yourname@yourdomain"; // SMTP account username
$mail->Password = "yourpassword"; // SMTP account password
$mail->SetFrom('noreply@mydomain.com', 'List manager');
$mail->AddReplyTo('list@mydomain.com', 'List manager');
$mail->Subject = 'Newsletter';
$ids = mysql_query($select, $connection) or die(mysql_error());
while ($row = mysql_fetch_row($ids)) {
$mail->AltBody = "To view the message, please use an HTML compatible email viewer!";
$mail->MsgHTML($body);
$mail->AddAddress($row[0]);
$mail->Send();//Sends the email
}