PHP - How to send emails to address on MYSQL? -
how can send emails emails on database? e.g. here format of mysql.
mysql -- table = users --- column = email. need send emails of email on column "email".
simple ready use php script sending mail mysql data
<?php mysql_connect("localhost", "mysql_user", "mysql_password") or die("could not connect: " . mysql_error()); mysql_select_db("mydb"); $result = mysql_query("select email mytable"); while ($row = mysql_fetch_array($result, mysql_num)) { sendmail($row[0]); } mysql_free_result($result); function sendmail($to){ $subject = 'the subject'; $message = 'hello'; $headers = 'from: webmaster@example.com' . "\r\n" . 'reply-to: webmaster@example.com' . "\r\n" . 'x-mailer: php/' . phpversion(); mail($to, $subject, $message, $headers); } ?>
Comments
Post a Comment