How to mass mail with Phpmailer
Csdn's moderators are embarrassed to bother you again.
I have a database inside such as 10 email address, how do I get him, and then push the button to send a mass out
According to the post I asked yesterday
http://bbs.csdn.net/topics/390967296?page=1#post-398769890
Library name email, table name bl_email, field email
------to solve the idea----------------------
Just say a few 2 ways, but try to discuss the problem again.
1. The 2-page process you mentioned in your previous post
Get 10 emails from a.php (select email from bl_email where ...)
Then sumit the form post to b.php processing the delivery action
2. Do not change pages with Ajax
Get 10 emails from a.php (select email from bl_email where ...)
Press the button and use the Ajax post 10 email to the backend b.php processing the delivery action
------to solve the idea----------------------
Reference:
reply 1 floor
Why only one record is read
$conn =mysql_connect ("localhost", "root", "");//Connect to Database
mysql_select_db ("email", $conn);//Connect which library
mysql_query ("Set names Utf-8");//Encoding method
$sql = "SELECT * from Bl_email";//Query the table
$result =mysql_query ($sql, $conn);
while ($array =mysql_fetch_array ($result)) {
$email = $array ["Address"];
};
Print_r ("$email");
?>
Use this to see what results are printed out.
Print_r (Mysql_fetch_array ($result));
------to solve the idea----------------------
Reference:
I directly put the above variable to the above.
$mail->addaddress ("$email", "H"); Add recipients
This can be submitted, that is, the mail is not sent over
$mail->addaddress ("$email", "H");
Switch
foreach ($email as $em) {
$mail->addaddress ("$em", "H");
}
------to solve the idea----------------------
Reference:
I directly put the above variable to the above.
$mail->addaddress ("$email", "H"); Add recipients
This can be submitted, that is, the mail is not sent over
if (! $mail->send ()) {
echo "Send failed:". $mail->errorinfo;
}
------to solve the idea----------------------
if (Is_array ($email))
If it's not an array, you didn't write it.
------to solve the idea----------------------
The array before the while should not be defined?
An array is automatically created $email [].