In my case I need to echo a flag to client side and send an email .
Now client side needs to wait until the email is sent...
But I want to separate these two steps,how to do that?
In my case I need to echo a flag to client side and send an email .
Now client side needs to wait until the email is sent...
But I want to separate these two steps,how to do that?
You could take a look at Gearman
You could take a look at Run PHP Task Asynchronously which is pretty much what you want to accomplish.
Have another php file to send emails, and call it with some parameters using shell_exec . You can also call the URL on command line using CURL with some parameters.
That would work fine, you can track your email success status in the target file.
pseudo code:
my main file :
You can use pcntl_fork() function for that. With pcntl you can fork processes to child process with different pid.
http://php.net/manual/en/function.pcntl-fork.php