So senden Sie mehrere E-Mails in PHP und MySQL via phpmailer

Habe ich ein problem. Wenn ich auf senden-Taste, nur [email protected] die Nachricht erhält.

Wie es zu ändern? Ich bin mit Gmail SMTP senden.

Gibt es 2 Datensätze in der Datenbank:

Hier ist mein code:

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');
}
InformationsquelleAutor tommychoo | 2012-05-11
Schreibe einen Kommentar