Web Hosting Talk







View Full Version : A free gift :)


Rewdog
12-05-2001, 02:28 AM
This will simply take all the client's emails out of the plesk database and will send them an email you specify. All you have to do is change the sql password. We use it to report outages and a monthly newsletter. Enjoy!

<?php
###########################################################################################
## SITE SETTINGS ##
###########################################################################################
$sql_host = "localhost";
$sql_user = "admin";
$sql_pass = "*******";
$sql_db = "psa";

mysql_connect("$sql_host", "$sql_user", "$sql_pass");
mysql_select_db("$sql_db") or die ("Unable to select database");

###########################################################################################
## SOME CHECKS TO BE SURE EVERYTHINGS IS OK ##
###########################################################################################
if (eregi("^[_\.0-9a-z-]+\@([0-9a-z-]+\.)+[a-z]{2,3}$", $from_email))
{
$email_check = "1";
}
else
{
$email_check = "0";
}

if ($subject != "")
{
$subject_check = "1";
}
else
{
$subject_check = "0";
}

if ($content != "")
{
$content_check = "1";
}
else
{
$content_check = "0";
}

###########################################################################################
## SEND MESSAGE TO CLIENTS ##
###########################################################################################
if ($action == "submit")
{
if ($email_check == "1" && $subject_check == "1" && $content_check == "1")
{
$sql_query = mysql_query("select email from clients");

while ($row = mysql_fetch_object($sql_query))
{
$clients_found = ($clients_found + 1);
echo "Sending message to $row->email...<br>";

mail("$row->email", "$subject", $content, "From: $from_email\r\n"."Reply-To: $from_email\r\n"."X-Mailer: PHP/" . phpversion());
}

echo "<br><b>Finished, $clients_found messages sended away...</b>";

exit;
}

if ($email_check == "0")
{
$from_email_font = "<font color=\"#FF0000\">";
}

if ($subject_check == "0")
{
$subject_font = "<font color=\"#FF0000\">";
}

if ($content_check == "0")
{
$content_font = "<font color=\"#FF0000\">";
}
}

###########################################################################################
## MAIN FUNCTION ##
###########################################################################################
echo "<style>\n";
echo "body {font-face: verdana; font-size:12px}\n";
echo "font {font-face: verdana; font-size:12px}\n";
echo "form {font-face: verdana; font-size:12px}\n";
echo "select {font-face: verdana; font-size:12px}\n";
echo "input {font-face: verdana; font-size:12px}\n";
echo "textarea {font-face: verdana; font-size:12px}\n";
echo "</style>\n";
echo "\n";
echo "<form action=\"$PHP_SELF\" method=\"post\">";
echo "<input type=\"hidden\" name=\"action\" value=\"submit\">";
echo "$from_email_font<b>From email.:</b></font><br><input type=\"text\" name=\"from_email\" size=\"50\" value=\"$from_email\">&nbsp;<b>No fake email... {someone@someone.com}</b><br><br>";
echo "$subject_font<b>Subject.:</b></font><br><input type=\"text\" name=\"subject\" size=\"50\" value=\"$subject\"><br><br>";
echo "$content_font<b>Content.:</b></font><br><textarea rows=\"12\" cols=\"65\" name=\"content\">$content</textarea><br><br>";
echo "<input type=\"submit\" value=\"Send message to all clients...\">";
echo "</form>";

?>