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!

Send mail via scheduled server task, not via browser

Status
Not open for further replies.

lennyh

Programmer
Sep 22, 2001
33
0
0
US
I'd like to trigger the sending of emails via a server initiated scheduled task (e.g. once a day at 10:am) rather than in conjunction with a browser request. I am familiar with the use of mail() within a browser page, but don't know how I might use this via a schedulted server task. Is there a way to do this w/ php? Or if not w/ php, is there another way to do it?

Thanks for any help you can provide.
 
What version of PHP are you using on what platform?

If you're using a fairly recent version of PHP on Linux, then PHP is available as a stand-alone interpreter. You can use cron to schedule a job consisting of a PHP script.


Want the best answers? Ask the best questions: TANSTAAFL!!
 
Thank you for your response.

I am doing my testing w/ localhost on my WinXP Home system. The php version is 4.3.1. (The real production server is Win 2K.)

Since making my original post, I've been doing some experimentation on my local machine and it would appear that the following may work (roughly equivalent to your suggestion):

1. Set up scheduled task to run a cmd line which looks something like:
c:\php\php mailit.php

2. In mailit.php, include the same mail(} code that would have been included in a page normally invoked w/ a browser, but w/o including any html (that is, w/o sending any info back to the browser.

For unrelated admin reasons, I haven't as yet been able to test this out on the real server, but I am hopeful.

What do you think? Am I missing something?

Lenny
 
You might want to try queue the mail in a mysql database. Then when 10AM comes around your script will pull them out and send them. Beware though, depending on who you are sending mail to, you might get labeled as a spammer. Putting in wait statements would help. Then you might run into your php script running longer than is definded in php.ini. Hope that helps.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top