Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Mail function - working in background

Status
Not open for further replies.

d0nny

IS-IT--Management
Dec 18, 2005
278
GB
I've written a small function that essentially collects a load of emails from the (mySQL) database and creates an email to send out.
The email is created in a RTE (TinyMCE) and the Admin user then clicks on a button to send the email to his selected mailing list.

What I want to do is have that mailout function work in the background whilst a page is returned to the Admin user stating the email has been queued, or something similar.
At the moment, because of restrictions on the mail server, I need to 'sleep' my mailout loop but I don't want the Admin user to be waiting for the function to finish before they get a server response.

So how would I kick into action the function in the background whilst I return a 'finished' page to the user?
 
Hi

I see things evolved here.

Regarding the suggested AJAX solution, note that the web servers used to kill the scripts when the request is closed. So if mailingloop.php is requested by AJAX and the user navigates away from the page which issued the request, the AJAX request will be closed and the web server will kill the PHP script soon.

However given the highly customized system you use, this may or may not apply. But I would develop this in small steps, testing often, as I am afraid will not work reliably.

Feherke.
[link feherke.github.com/][/url]
 

Yes, it would seem that my host doesn't allow this. I'm using a reseller package which ultimately means its shared hosting and apparently they don't allow this on shared hosting. Might be time to look at a dedicated server!

And yes, I was afraid that might be the case with AJAX and navigating to another page, which I would assume my user(s) would do. I can't see a mass mailing script completing within a few minutes in the time it takes the user to go somewhere else (to another page or do another action) and then the AJAX will just halt.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top