phpapacheemailvirtual-server

PHP script makes my website inaccessible for that user


I've just recently been asked to develop a PHP application that allows mass emailing. To do this, I have a PHP script that simply grabs the email addresses from a MySQLDatabase and loops through them personalising each one, and then sending them.

It works absolutely fine, however we have a slight issue in that whilst this PHP script is running (and it obviously takes several minutes to run) the user cannot do anything else on the application. Other people can access it, but the user in question cannot load any other page of the application whilst the emails are sending.

Is there some way of dealing with this or is this just something we are going to have to live with?


Solution

  • The user in this case has a session open to the page, which is currently processing a PHP page. Because of this the user is unable to open (in the same session) another page on the same site.

    A way of handling this is initiate this process by the user, but don't let the script the user is accessing send the e-mails. You could for example make a "todo" list in the database, and let a cronjob handle it. This way the user is still able to visit other pages.