Anhat Singh Anhat Singh - 1 month ago 7
JSON Question

PHP execution in a hidden way

Ok , Now I have a php code at http://www.anhatweb.tk/web/auth/create to create a new user ....

What I do is I send my data using POST to add into MySQL database and then send a mail to user for account verification.....since I am using a free website to host my website, the SMTP server is slow and sometimes takes very very large time to send mail making the page slow to load for the user.

What I want to do is to upload data into database then send mail in background without letting user experience the slow sending......

My mail code is simple...just basic PHP
Any other methods such as JSON,Jquery etc etc are appreciated but PHP is preferred


in short: I want to run php code in background without making server send any success/failure response to the user to the same page! Just run and redirect without the slow loading

Answer

You can push email to queue. And email workers listen this queue and when mail exist, send it to user. This mechanism used by framework Laravel. Queues and workers may have many implementations. For example queue is sql database, and worker is cronjobed script which execute every seconds and checks db

Comments