我有个问题。当我单击发送按钮时,只会zxc@hotmail.com
收到消息。
如何改变它?我正在使用 Gmail SMTP 发送出去。
数据库中有2条记录:
这是我的代码:
include "phpmailer/class.phpmailer.php";
$host = "localhost";
$user = "root";
$pass = "root";
$db = "mailTest";
mysql_connect($host, $user, $pass);
mysql_select_db($db);
$query = "SELECT email FROM list";
$recordset = mysql_query($query);
$row_recordset = mysql_fetch_assoc($recordset);
$tota_row_recordset = mysql_num_rows($recordset);
$msg = strip_tags($_POST['msg']);
$mail= new PHPMailer(); //建立新物件
while($row = mysql_fetch_array($recordset))
{
$to = $row['email'];
$mail->AddAddress($to, "Test Message");
}
$mail->IsSMTP();
$mail->SMTPAuth = true;
$mail->SMTPSecure = "ssl";
$mail->Host = "smtp.gmail.com";
$mail->Port = 465;
$mail->CharSet = "big5";
$mail->Subject = "Test Message";
$mail->Username = "xxxxxx";
$mail->Password = "xxxxxx";
$mail->Body = "$msg";
$mail->IsHTML(true);
if(!$mail->Send()) {
echo "Mailer Error: " . $mail->ErrorInfo;
} else {
header('Location: index.php');
}