Jump to content

Output to browser during execution (ob_flush?)


opalelement

Recommended Posts

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

<?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.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.