How to mass mail with Phpmailer

Source: Internet
Author: User
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 [].
  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.