The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums Back End Sending email to selected email addresses from mysql databasein php

  • This topic is empty.
Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
  • #161145

    I want to send email to selected email addresses that are in mysql database from php..The below code will send to all, but I can’t quite figure out how to setup a form to select email addresses to send to:

    From = ‘[email protected]’;
    $mailer->FromName = ‘Georgia Sting Admin’;
    $mailer->Body = ‘TEST EMAIL’;
    $mailer->Subject = ‘This is the subject of the email’;

    mysql_select_db($database_MySQL, $MySQL);
    $query_rs30dayevents = “SELECT, pro.check FROM pro WHERE pro.check=1″;
    $rs30dayevents = mysql_query($query_rs30dayevents, $MySQL) or die(mysql_error());
    $row_rs30dayevents = mysql_fetch_assoc($rs30dayevents);
    $totalRows_rs30dayevents = mysql_num_rows($rs30dayevents);

    // get email addresses from db base
    while( $data = mysql_fetch_assoc($rs30dayevents))
    // make SURE we are not sending this to each and every recipient incrementally.
    // alternately, you can use $mailer->ClearAllRecipients(); ClearAddresses();
    // send it to THIS user…

    print ($mailer->Send()) ? "Message sent to: " : "Message not sent to: ";
    print $data["email"]."



    Can anyone help…


    This is the sql that determines which email addresses are retrieved:

    SELECT, pro.check FROM pro WHERE pro.check=1

    …in other words, if the pro.check column holds the value 1, it will be selected. If you want to select emails by some other criteria, you’ll need to figure out what that criteria is, and then we can figure out how to filter it.

    If you’re talking about selecting specific email addresses (manually), then you’d need to select all of them beforehand and load them into a <select> field so you can choose them when you fill out the form.

Viewing 2 posts - 1 through 2 (of 2 total)
  • The forum ‘Back End’ is closed to new topics and replies.