PHP Scripts

Mailout from a MySQL database

Read your database, and send every entry a personal email

<?php

$db = mysql_connect(host,name,password);
mysql_select_db(database,$db);

// the database has fields: name, email, hits

$sql = mysql_query("SELECT * FROM table WHERE email !='' AND hits !=''",$db);
// above to MAKE SURE NO email goes to a blank adress, or with 0 hits.

while ($row = mysql_fetch_array($sql)) {
$line="your_signature_line"; // type what you like here as a sign-off
$v = $row["name"];
$h = $row["hits"];

if (!mail($row["email"],
$subject = "your_subject_line",
$message = "1st line of message.Hi there $v.\n\n2nd line of message.\n\n
Your page had $h visitors this month\n\n
Best regards,\n$line"))
{
echo "<FONT FACE=VERDANA, ARIAL SIZE=2>Error : Mail not sent to " . $row["email"] . "</FONT><BR>\n";
} else {
echo "<FONT FACE=VERDANA, ARIAL SIZE=2>Stamped, sealed and delivered to " . $row["email"] . "</FONT><BR>\n";
}

}

mysql_close($db);
?>

 

Back