Page 3 of 3

Posted: Thu Jul 15, 2004 10:33 pm
by furiousweebee

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. :(

Posted: Thu Jul 15, 2004 10:45 pm
by feyd
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>'; 
   } 
} 
?>

Posted: Thu Jul 15, 2004 11:15 pm
by furiousweebee
Hmmm... now it doesn't send emails, and on the confirmation/error message page after submission, it's completely blank.

Posted: Thu Jul 15, 2004 11:17 pm
by feyd
you may want to echo $admin_forms after the loop.

Posted: Thu Jul 15, 2004 11:20 pm
by furiousweebee
Like this? :?

Code: Select all

'Email to '.$row['email'].' was successful.<br>': 
   '<strong>Email to '.$row['email'].' has failed.</strong><br>';
   } 
} 
<? echo "$admin_forms"; ?>

Posted: Thu Jul 15, 2004 11:28 pm
by feyd
basically..

Posted: Thu Jul 15, 2004 11:32 pm
by furiousweebee
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>';
}