PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
Moderator: General Moderators
furiousweebee
Forum Commoner
Posts: 69 Joined: Sun Jul 11, 2004 7:38 am
Location: Brisbane, Australia
Contact:
Post
by furiousweebee » Thu Jul 15, 2004 10:33 pm
Code: Select all
<?php
$res = mysql_query("SELECT email FROM mailing_list", $mysql_conn);
$filedata = file_get_contents('template.html');
if (@$_POST['send'] == 'yes'){
while ($row = mysql_fetch_assoc($res)){
$row['message'] = $_POST['message']; // add the handle for {message} tag
$replace_for_msg = preg_replace('#\{([^\}]+?\}#e','repData("\\1",$row)',$filedata);
$headers = "MIME-Version: 1.0\r\n";
$headers .= "Content-type: text/html; charset=iso-8859-1\r\n";
$headers .= "From: Mailing List <xx@xxxx.com>\r\n";
$headers .= "Return-Path: Mailing List <band@tenfootpole.com>\r\n";
$admin_forms .= mail($row['email'], $_POST['subject'],$replace_for_msg,$headers)?
'Email to '.$row['email'].' was successful.<br>':
'<strong>Email to '.$row['email'].' has failed.</strong><br>';
}
}
?>
Now it doesn't send the email at all. Man I suck.
feyd
Neighborhood Spidermoddy
Posts: 31559 Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA
Post
by feyd » Thu Jul 15, 2004 10:45 pm
hmm noticed something.. try this
Code: Select all
<?php
$res = mysql_query("SELECT email FROM mailing_list", $mysql_conn);
$filedata = file_get_contents('template.html');
if (@$_POST['send'] == 'yes'){
while ($row = mysql_fetch_assoc($res)){
$row['message'] = $_POST['message']; // add the handle for {message} tag
$replace_for_msg = preg_replace('#\{([^\}]+?)\}#e','repData("\\1",$row)',$filedata);
$headers = "MIME-Version: 1.0\r\n";
$headers .= "Content-type: text/html; charset=iso-8859-1\r\n";
$headers .= "From: Mailing List <xx@xxxx.com>\r\n";
$headers .= "Return-Path: Mailing List <band@tenfootpole.com>\r\n";
$admin_forms .= mail($row['email'], $_POST['subject'],$replace_for_msg,$headers)?
'Email to '.$row['email'].' was successful.<br>':
'<strong>Email to '.$row['email'].' has failed.</strong><br>';
}
}
?>
furiousweebee
Forum Commoner
Posts: 69 Joined: Sun Jul 11, 2004 7:38 am
Location: Brisbane, Australia
Contact:
Post
by furiousweebee » Thu Jul 15, 2004 11:15 pm
Hmmm... now it doesn't send emails, and on the confirmation/error message page after submission, it's completely blank.
feyd
Neighborhood Spidermoddy
Posts: 31559 Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA
Post
by feyd » Thu Jul 15, 2004 11:17 pm
you may want to echo $admin_forms after the loop.
furiousweebee
Forum Commoner
Posts: 69 Joined: Sun Jul 11, 2004 7:38 am
Location: Brisbane, Australia
Contact:
Post
by furiousweebee » Thu Jul 15, 2004 11:20 pm
Like this?
Code: Select all
'Email to '.$row['email'].' was successful.<br>':
'<strong>Email to '.$row['email'].' has failed.</strong><br>';
}
}
<? echo "$admin_forms"; ?>
feyd
Neighborhood Spidermoddy
Posts: 31559 Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA
Post
by feyd » Thu Jul 15, 2004 11:28 pm
basically..
furiousweebee
Forum Commoner
Posts: 69 Joined: Sun Jul 11, 2004 7:38 am
Location: Brisbane, Australia
Contact:
Post
by furiousweebee » Thu Jul 15, 2004 11:32 pm
Hmm, here's what I put. It didn't make a difference unfortunately.
Code: Select all
$admin_forms = '';
switch (@$_GET['act']){
case 'mail':
if (!connect_db()){
$admin_forms = 'Error connecting to database, '.mysql_error().'.';
} else {
$res = mysql_query("SELECT email FROM mailing_list", $mysql_conn);
$filedata = file_get_contents('template.html');
if (@$_POST['send'] == 'yes'){
while ($row = mysql_fetch_assoc($res)){
$row['message'] = $_POST['message']; // add the handle for {message} tag
$replace_for_msg = preg_replace('#\{([^\}]+?)\}#e','repData("\\1",$row)',$filedata);
$headers = "MIME-Version: 1.0\r\n";
$headers .= "Content-type: text/html; charset=iso-8859-1\r\n";
$headers .= "From: Mailing List <xx@xxxx.com>\r\n";
$headers .= "Return-Path: Mailing List <xx@xxxx.com>\r\n";
$admin_forms .= mail($row['email'], $_POST['subject'],$replace_for_msg,$headers)?
'Email to '.$row['email'].' was successful.<br>':
'<strong>Email to '.$row['email'].' has failed.</strong><br>';
}
}
echo "$admin_forms";
}
break;
case 'logout':
header("Location: ../index.php");
break;
default:
$admin_forms = $form['mail'].'<a href="?act=logout">Log Out</a>';
}