Link to home
Start Free TrialLog in
Avatar of Neil_Bradley
Neil_BradleyFlag for New Zealand

asked on

ob_get_clean();

The code attached below works. An html email message is sent in the function called display_email(); using this code:
ob_start();
display_email();
$msg .= ob_get_clean();

I have constructed the actual message in a function as the email contained quite a bit of dynamic informaion and it seemed to be the only way I could get the email to send its content.

My question relates to an errror I recieve in de bug mode that states that the variable $msg is undefined. My code works, everying seems to function just fine hower I would preref to figure out what the undefined $msg variabke is all about. Especially as the $msg is there when it pop out as an email message.
Thanks,
N
$headers  = 'MIME-Version: 1.0' . "\r\n";
				$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
				$headers .= "Reply-To: ".$_POST['fp']['Contact Email Address'][0]." \r\n";
				$headers .= "From: ".$_POST['fp']['Contact Email Address'][0]."\r\n";
				
           // Send
                $subject = $_POST['subject'];
           		$to      = "someemail@somedoman.com" ;
			
		
ob_start(); 
display_responce($_POST['heading'], $_POST['subject'], $_POST['fp'], $_POST['sf']);
$msg .= ob_get_clean(); 
 
        mail($to, $subject, $msg, $headers);

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of Dave Baldwin
Dave Baldwin
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Neil_Bradley

ASKER

Thanks  Dave an Ray, between you, you have solved and answered my question thoroughly. I am pleased to resolve the $msg .= ob_get_clean(); issue as its the only way I have found to send an email containing code other than simple echoed  strings.
Cheers,
N