opalelement Posted January 4, 2009 Share Posted January 4, 2009 I have the following script below, sending mail from a list (comma separated) or email addresses: <?php $from = $_POST['from']; $to_whole = $_POST['to']; $subject = $_POST['subject']; $message = $_POST['message']; $to = explode(",", $to_whole); for($i = 0; $i < count($to); $i++) { mail($to[$i], $subject, $message, "From: $from"); } ?> What I want it to do is after each mail is sent, show a message that says so. I have read that I should use ob_flush to do this, but I am completely lost on how to do it. All examples I have read say something different, but I can never get it to work. Can anyone here help me? Thanks, .:Opalelement:. Quote Link to comment https://forums.phpfreaks.com/topic/139393-output-to-browser-during-execution-ob_flush/ Share on other sites More sharing options...
premiso Posted January 4, 2009 Share Posted January 4, 2009 <?php $from = $_POST['from']; $to_whole = $_POST['to']; $subject = $_POST['subject']; $message = $_POST['message']; $to = explode(",", $to_whole); for($i = 0; $i < count($to); $i++) { mail($to[$i], $subject, $message, "From: $from"); echo "Mail Sent to " . $to[$i] . "<br />"; ob_flush(); flush(); } ?> Should do it. Quote Link to comment https://forums.phpfreaks.com/topic/139393-output-to-browser-during-execution-ob_flush/#findComment-729092 Share on other sites More sharing options...
DarkWater Posted January 4, 2009 Share Posted January 4, 2009 By the way, that won't work in all browsers or all servers. There is no browser/server-independent way of doing that. Quote Link to comment https://forums.phpfreaks.com/topic/139393-output-to-browser-during-execution-ob_flush/#findComment-729093 Share on other sites More sharing options...
opalelement Posted January 4, 2009 Author Share Posted January 4, 2009 Couldn't get it to work because I was in google chrome Works now for other browsers, thanks:) Quote Link to comment https://forums.phpfreaks.com/topic/139393-output-to-browser-during-execution-ob_flush/#findComment-729124 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.