I want to run a PHP script that will send a bunch of letters (newsletters), but since it may take some time, I want the user to be immediately redirected to a page with a message like "Your newsletters are queued for sending."
So far, redirection of headers works, but they do not cause redirection until all letters have been sent. Can I close the connection after sending the redirect so that the browser redirects immediately? I tried such things
ob_start(); ignore_user_abort(true); header( "refresh:1;url=waitforit.php?msg=Newsletters queued up, will send soon."); header("Connection: close"); header("Content-Length: " . mb_strlen($resp)); echo $resp; //@ob_end_clean(); ob_end_flush(); flush();
in various permutations and combinations, but to no avail. I suspect this cannot be done so simply, but before I start messing with cron jobs or user daemons, I thought I'd consider this approach. Thanks
like for example a blockhead but no luck
ob_start(); ignore_user_abort(true); header( "refresh:1;url=mailing_done.php?msg=Newsletters queued for sending."); header("Connection: close"); header("Content-Length: 0" ); //echo $resp; ob_end_flush(); flush();
redirect php header
lost baby
source share