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:. 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. 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. 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:) 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
Archived
This topic is now archived and is closed to further replies.