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

Link to comment
Share on other sites

<?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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.