Newsletter problem
Hi,
I have created a PHP script to send out a newsletter to a single email address. Format is spot on on recipient email account. What I want to do now is for every email address in a table, I want to send the newsletter to them all, but its only sending out 1 and then nothing else.
Here is my table:
Table name : test
Fields: email varchar2(20)
main php script (test version)
<html>
<title>email test</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<link href="./../Style/Format.css" rel="stylesheet" type="text/css">
</head>
<body class="body" bgcolor="#FFFFFF" text="#000000" topmargin="2">
<?php
$month='March';
$year='2010';
$date_start='2010-03-01';
$date_finish='2010-03-31';
?>
<div align="center">
<?php include("db.php"); ?>
<br>
<?php
$result1 = mysql_query("SELECT * FROM test")
or die(mysql_error());
while($row1 = mysql_fetch_array( $result1 ))
{
include("./email_test.php");
}
?>
</body>
</html>
email_test.php
<?php
$to = $row1['email'];
$subject = $month.' '.$year.' Newsletter';
$random_hash = md5(date('r', time()));
$headers = "MIME-Version: 1.0\n";
$headers .= "From: test@test.Com>\r\nReply-To: test@test.com";
$headers .= "\r\nContent-Type: multipart/alternative; boundary=\"PHP-alt-".$random_hash."\"";
ob_start();
?>
--PHP-alt-<?php echo $random_hash; ?>
Content-Type: text/plain; charset="utf8"
Content-Transfer-Encoding: 7bit
<div align="center">Having trouble viewing this email? <a href="http://www.test.com/<?php echo $month.$year.".php";?>">Web Version</a></div><br><br>
--PHP-alt-<?php echo $random_hash; ?>
Content-Type: text/html; charset="utf8"
Content-Transfer-Encoding: 7bit
<?php
$result3 = mysql_query("xxxxxxx")
or die(mysql_error());
while($row3 = mysql_fetch_array( $result3 ))
{
include("./news_boxes.php");
}
?>
--PHP-alt-<?php echo $random_hash; ?>--
<?
$message = ob_get_clean();
$mail_sent = @644699( $to, $subject, $message, $headers );
echo $mail_sent ? "Mail sent" : "Mail failed";
?>
Like i said, i get one email received (1st record), there are 5 test records in my table. Am I missing something as im sure im looping around the table?
Thanks.
