Forums
This topic is locked
E-mail Probelems
Posted 08 Feb 2006 02:50:03
1
has voted
08 Feb 2006 02:50:03 chris smith posted:
The following code fails to deliver a subscriber based e-mail. I've checked the database and the e-mails are being collected. Also, site is being hosted on a Windows server.Thanks in advance!
<?
require_once("../conn.php"
require_once("access.php"
include_once("LeftStyles.php"
if(isset($_POST[s1]))
{
//get the subscribers info
$q1 = "select * from re2_agents where news = 'y' ";
$r1 = mysql_query($q1) or die(mysql_error());
while($a1 = mysql_fetch_array($r1))
{
$to = $a1[email];
$subject = $_POST[subject];
$headers = "MIME-Version: 1.0\n";
$headers .= "Content-type: text/$a1[NewsletterType]; charset=iso-8859-1\n";
$headers .= "Content-Transfer-Encoding: 8bit\n";
$headers .= "From: $_SERVER[HTTP_HOST] <$aset[ContactEmail]>\n";
$headers .= "X-Priority: 1\n";
$headers .= "X-MSMail-Priority: High\n";
$headers .= "X-Mailer: PHP/" . phpversion()."\n";
if($a1[NewsletterType] == "plain"
{
$message = strip_tags($_POST[message]);
$message .= "\n\n========================\nTo unsubscribe, use this link:\n";
$message .= "$site_url/u.php?id=$a1[AgentID]";
}
else
{
$message = $_POST[message];
$message .= "<br><hr width=\"100%\" size=1 color=black>Click <a href=\"$site_url/u.php?id=$a1[AgentID]\">here</a> to unsubscribe.";
}
$message = stripslashes($message);
mail($to, $subject, $message, $headers);
$i++;
}
//add the message to the mail archive
$t = time();
$q1 = "insert into re2_mail_archive set
subject = '$_POST[subject]',
message = '$_POST[message]',
MailDate = '$t' ";
mysql_query($q1) or die(mysql_error());
echo "<center><b>$i emails was sent!</b></center><br>";
}
//get the subscribers number
$q1 = "select count(*) from re2_agents where news = 'y' ";
$r1 = mysql_query($q1) or die(mysql_error());
$a1 = mysql_fetch_array($r1);
if($a1[0] == '0')
{
echo "<br><center><font face=verdana size=2 color=red><b>You have no subscribers at your mailing list!";
exit();
}
?>
<script>
function CheckNews() {
if(document.f1.subject.value==""
{
window.alert('Enter your newsletter subject line!');
document.f1.subject.focus();
return false;
}
if(document.f1.message.value==""
{
window.alert('Enter your newsletter text!');
document.f1.message.focus();
return false;
}
}
</script>
<form method=post name=f1 onsubmit="return CheckNews();">
<table align=center width=350>
<caption align=center class=BlackLink>You have <?=$a1[0]?> subscribers at your mailing list.</caption>
<tr>
<td colspan=2 class=TableHead align=center>Send your newsletter</td>
</tr>
<tr>
<td>Subject:</td>
<td><input type=text name=subject size=38></td>
</tr>
<tr>
<td valign=top>Message:</td>
<td><textarea name=message rows=10 cols=32></textarea></td>
</tr>
<tr>
<td> </td>
<td><input type=submit name=s1 value=Send class=sub></td>
</tr>
</table>
</form>
Replies
Replied 09 Feb 2006 19:24:14
09 Feb 2006 19:24:14 Roddy Dairion replied:
What are u using to relay your mail??