Hello
I have a mailing list I wrote, but am having problems getting it to work properly with a large mailing list.
The problem, I believe, is this line of code; mail("$email", $subject, stripslashes($newsletter), $mailheaders);
The line below it displays the sent to result set. When sending either an email in Text or HTML the result set returns only 4 recipients. However if I comment the mail line of code to see if the connection to the database is returning the full list, it returns every subscibed e-mail which makes me think there is a problem with the mail syntax. Any advice would be greatly appreciated. I have included the code for the send.php I'm having problems with.
FYI; I have tried removing the stripslashes() and leaving just $newsletter with the same results.
NOTE: There are two mailing types; text or HTML so if you notice that the two while loops look similar that is why. I have commented out the HTML type for debugging reasons.
<?PHP
include("../config.php");
?>
<HTML>
<HEAD>
<TITLE>Send Newsletter</TITLE>
</HEAD>
<BODY bgcolor=EFEFEF>
<?
$connect = mysql_connect("$newsletter_hostname", "$newsletter_username", "$newsletter_password");
mysql_select_db("$newsletter_database", $connect);
echo "<h2 align=center>Send Newsletter</h2>";
if (!$submit)
{
echo "<FORM ACTION=\"$PHP_SELF\" METHOD=\"post\">
<center>
<table>
<tr>
<td>Subject:</td>
<td><input type=\"text\" name=\"subject\" size=\"40\"></td>
</tr>
<tr>
<td>Newsletter:</td>
<td><textarea rows=\"8\" name=\"newsletter\" cols=\"49\"></textarea></td>
</tr>
<tr>
<td colspan=\"2\">
<p align=\"center\"><b>Message Type</b></p>
<p align=\"center\"><input type=\"radio\" value=\"Text\" name=\"type\">Text
<input type=\"radio\" value=\"HTML\" name=\"type\">HTML</p>
<p align=\"center\">
<input type=\"submit\" value=\"Send Newsletter\" name=\"submit\"></td>
</tr>
</table>
</center>
</form>";
}
else if ($submit && empty($subject) && empty($newsletter) && !$type)
{
echo "<center>You need to enter a subject and newsletter.</center>";
}
else if ($submit && !empty($subject) && !empty($newsletter) && $type == "Text")
{
$date = date("Y-m-d");
$insert = "INSERT INTO newsletter_archive (id, subject, type, newsletter, date)
VALUES ('', '$subject', '$type', '$newsletter', '$date')
";
$insert_res = @($insert) or die("No.");
$sql = "SELECT * FROM subscriber";
$result = @($sql)
or die("Couldn't execute query.");
while ($row = mysql_fetch_array($result))
{
$email = $row['email'];
$from = "Front Office";
$mailheaders = "From: $from <> \n";
$newsletter .= $msg;
mail("$email", $subject, $newsletter, $mailheaders);
echo "<center>newsletter sent to: <b>$email</b><br></b>";
}
}
else if ($submit && !empty($subject) && !empty($newsletter) && $type == "HTML")
{
$date = date("Y-m-d");
$insert = "INSERT INTO newsletter_archive (id, subject, type, newsletter, date)
VALUES ('', '$subject', '$type', '$newsletter', '$date')
";
$insert_res = @($insert) or die("No.");
$sql = "SELECT * FROM subscriber";
$result = @($sql)
or die("Couldn't execute query.");
while ($row = mysql_fetch_array($result))
{
$email = $row['email'];
$mailheaders = "From: $list <> \n";
$mailheaders .= "Content-type: text/html; charset=iso-8859-1\r\n";
$newsletter .= $msg;
// mail("$email", $subject, stripslashes($newsletter), $mailheaders);
echo "<center>newsletter sent to: <b>$email</b><br></b>";
}
}
mysql_close($connect);
?>
</BODY>
</HTML>