Hey,
How can I send emails to all emails on my database? E.g. here is my format of MYSQL.
MYSQL -- Table = users --- column = email. I need to send emails to everyone of the email on column "email".
Thanks if anyone can help me out.
Hey,
How can I send emails to all emails on my database? E.g. here is my format of MYSQL.
MYSQL -- Table = users --- column = email. I need to send emails to everyone of the email on column "email".
Thanks if anyone can help me out.
Simple ready to use PHP script for sending mail from 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 FROM 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: [email protected]' . "\r\n" .
'Reply-To: [email protected]' . "\r\n" .
'X-Mailer: PHP/' . phpversion();
mail($to, $subject, $message, $headers);
}
?>
Do you know how to pull data from MySQL? if so, you should just execute the mail() function for each row.
The code that JapanPro suggested is great! However, I have read over the internet about doing this. If there is loads of emails to be sent it will take a long time and possible slow down your server and clog it up. I would recommend doing it in intervals. So like in sets of 10 or 20.
This is only based on the information I have read. And I can se where they are coming from.