views:

534

answers:

3

I have a php script that does some processing (creates remittance advice PDFs, self-billing invoices, Sage CSV file etc...) and at the end outputs a screen with a form, in which the names and e-mail addresses of the people paid appear. User makes a selection of names by clicking check boxes and then there is a Send button which sends out emails with remittance advices and self-billing invoices attached. This all works nicely, BUT they now decided that when they click the Send button, they would like the e-mails to be sent NOT straight-away, but at 6.00pm.

Is it possible to set the dispatch time of the message in the SMTP header? Can the MS Exchange server be configured so that e-mails from a particular sender will be held until a certain time before they get sent? IT Support dept. claim it used to be possible in the old days of dial-up connections when it was simply cheaper to send stuff at night... but that this functionality was removed. Is this true? I have no idea how hard is the task at hand. It seems very straightforward and I guess it really is a task for the IT support guys to handle. But maybe I am wrong?

If this can not be set up at the Exchange server side, how could I go about achieving the requested functionality? And, no, this is not an exact duplicate of this question. I had a look at that but it didn't seem to answer my questions. Any help greatly appreciated!

Edit


Apache running on MS Windows Server 2003. Database is Oracle 10g. There will be no CRON set up. The email queue table would need to store all attachments too. I would like to avoid doing this at all cost. No way to specify dispatch time in header?

+10  A: 

You could save those emails into a database. And then create a cronjob PHP file that executes every few minutes to check if there are emails to be sent in the "queue" database.

Here's a tutorial on something like this.

Ólafur Waage
+1 for CRON job
Chris Ballance
Thanks, so you reckon this will not be easily configured at the Exchange server side? SMTP headers? Such a simple task, it's just a pity it seems there won't be an accordingly simple solution.
Peter Perháč
I suggest to set more than 1 cron job, especially if you need to send many mails (like 2000+)In that case, the best solution to keep the smtp server healty is to set many cronjob, with about 10 minutes one from another, and every cron send about 300/400 mail, and store the report for each mail sent, and whatever problem may raise.I can even suggest you webcron.org, a free cron service.. hey, its free, dont yell if sometimes fail (or is late ;)
DaNieL
+1  A: 

Windows (non-server editions, at least) has a "Scheduled Tasks" control panel item similar to CRON. Just from looking at it briefly, you can probably write a PHP script which sends your mail "now," but run it using the CLI at whatever time you want to send the mail using Scheduled Tasks.

Shadow
Windows also had the "at" command, and introduced a new command line tool "schtasks" command line tool for managing scheduled tasks: http://support.microsoft.com/kb/814596
R. Bemrose
A: 

Actually you can do this. If you are using an exchange 2003 server, you can set up a different SMTP connector. Under the delivery options there is a way to change it from send always any scheudle you pick.

Here is a nice tutorial for setting one up. link text

One thing you will need to do is when you create the new SMTP connector, set it up with a different port to listen on. That way you can send to that one instead of the standard connector.

Dayton Brown