Thanks for the advice 🙂
I decided to go with something like this:
<?
include("../../config.php");
include("../db-connect.php");
if(isset($submit))
{
if(empty($validated))
{
echo "<center><br><br><br> Error.<br> Go <a class=TN href=mail.php> back</a> and make your choice. </center>";
exit;
}
if(empty($message))
{
echo "<center><br><br><br> You are trying to send blank email. <br> Go <a class=TN href=mail.php> back</a> and write some text. </center>";
exit;
}
if($_POST[validated] == 'yes')
{
$q1 = "select email, name from newsletter WHERE validated='yes' ";
$r1 = mysql_query($q1) or die(mysql_error());
$name = $r1["name"];
}
elseif($_POST[validated] == 'no')
{
$q1 = "select email, name from newsletter WHERE validated='no' ";
$r1 = mysql_query($q1) or die(mysql_error());
$name = $r1["name"];
}
while($a1 = mysql_fetch_array($r1))
{
$name = $a1["name"];
$message = " Dear $name \n\n\n $message";
$from = "From: info@kimberleys.net.au";
mail($a1[0], $subject, $message, $from);
}
echo "<center><br><br><br>The mail was sent successfully. </center>";
unset($validated);
exit;
}
?>
It is working however I am a bit concerned about security.
The script will be installed in a protected directory, do I need to add any code snippets to make it more secure?
Also, am I going to see problems like timeouts if i try and email 100's of members using this script?