:0) *BIGGRIN*
no im not a teacher at all
and im very happy if im stuck and somebody helps me out, so never mind
ok lets see:
the script is sending just one mail this is correct
ok you want to send the mail to some users from a mysql database
if you inserted the users somehow into the table i asume you can connect to the database and know how to query it.
so here is some more code that could help you on your quest
PHP Code:
// debug param first :0)
define('DEBUG', true);
// then make the db connect
// write the query thats selects the users you want to send the email
// you should query the fields explicit not by * if you dont need all of them
// if there is no condition like (active = 1)
// and you want them all to recieve the mail
// just delete the 'WHERE my condition' part
$query = "SELECT * FROM recipient_table WHERE my condition";
// perform the query and get the mysqlresult
$result = mysql_query($query);
// while the result list is not at its end
while ( $row = mysql_fetch_array($result, MYSQL_ASSOC) ) {
// everything inside the while loop is done for every user in the list
// to see what happens just try this in DEBUG mode
id ( DEBUG ) {
// $row is now a array that holds one row of the mysql result
// you can access the data by $row[mysql_tabel_column_name]
echo 'The Name: ' . $row[table_column_name] . ' <br />';
echo 'The Email: ' . $row[table_column_email] . ' <br />';
} else {
// if you have understand how this works
// you can change DEBUG to false
// to send the mail do something like this
$recipient_mail = $row[table_column_email];
$recipient_name = $row[table_column_name];
// the template stuff for ever user should be made here
// i leave this commented
// this is similar to the code you allready have the only difference is
// that the name should be changed and the result of this operation
// is stored in another variable so the original $mail_text
// is not overwriten so you can still use it inside this loop
// without reading the tamplates again and again
// $user_mail = str_replce('{$name}', $recipient_name, $mail_text);
// $mail_sent = mail($recipient_mail, $subject, $user_text, $header);
if ( $mail_sent ) {
echo 'Mail sent to: ' . $recipeint_name . ' <' . $recipient_mail . '$gt;<br />';
} else {
echo ' Error! :0) ';
}
}
}
i have written this without testing, you should just play around a bit with seme mysql selects and some while loops to get familiar with this
try some test loops that return somthing like this
HTML Code:
From Database:
Name: John Doe, Email john@doe.com
Name: Jane Doe, Email jane@doe.com
Name: the spas, Email the_spas@has_no_mail.com
....
thats it :0)
gl hf
ahhhh and by the way dont send mails to a big amount of recipients
you will kill the mailserver :0)
therefor use the mail header bcc: option or do the sendings in bundles
so you send 20 mails wait 10 seconds send 20 mails wait 10 sec.......