Unfortunately it doesn’t answer my question.
I’m glad you have found a way to make this work for you, but take into account that a user may want to continue doing stuff if it’s going to take some time to process all the emails. Or he might click reload by mistake or navigate back. What’s worse is that if there is an issue on the server the user might stay there looking at a screen when nothing is happening.
What I’m trying to say is that this is not a very good solution UX wise. As mentioned previously in this thread a more elegant solution would be to communicate with the server via websockets and show the user a nice toast when all the emails have been processed so he can continue working. Even better would be to handle the scheduling to a queue on the server.
I know you mentioned that you are not on nodejs so all that is out of the equation. My advise is that unless you are developing this for a client that requires your work to be strictly in PHP/ASP or you don’t get paid you should consider migrating to nodejs which will allow you to develop more elegant solutions to the issues you encounter now and in the future.