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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Force Mail Delaying. 2

Status
Not open for further replies.

Sleidia

Technical User
May 4, 2001
1,284
FR
Hello,

Does anyone know if there is a way to send a mail with PHP making sure that the recipient will get the mail after a certain amount of time has passed?

Thank you very much.
 
well, it's not php based, but you can utilize the at daemon using exec() function
 
Hello Piti and thanks a lot for your recommendation.
Unfortunately, it seems that "cron jobs" and "at deamon" are designed for frequently scheduled tasks.
In my case, I just want to apply a delay upon the delivery time of an email sent by PHP. And the delay has to be different each time an email is sent.

For example, each time an email is sent after a form submission, an email would be sent with a delay randomly chosen between 5min and 6 hours.

If I use cron jobs, I will have to set up a cron job each time I'm willing to send an email and delete it after the mail is sent.

Any idea?
Thanks again :)
 
i said use at, not cron
at executes command at specific time and that's it, cron is a kind of repeating scheduler :)
if you issue
a) echo "mkdir /home/mails" | at now +3min
in 3 minutes there will be a directory mails created in the /home dir
b) at now +5hours -f command.txt
in 5 hours all commands from the file command.txt will be executed

after execution the command is deleted from the queue

so just create a php script, lets say mailnow.php, and in your submit script use:
exec('echo "/usr/bin/lynx -dump | at now +'.$time);
and that should do the job

hope that helps
 
Hello Piti.
Thanks a lot. It's a pity I can't give you more than one star :)

Anyway, thanks to you I've understood the purpose of AT deamon, but unfortunately I can't find any relevant information about how to install and use it on FreeBSD.
I'll search again but I'm affraid I'll have to stick to Cron.

Have a nice day!
 
at is part and parcel with ost cron installs, type
man at

for more info, or to list at job queues :
at -l (should work)

if you get anything that says at is not installed I will be suprised :) ______________________________________________________________________
There's no present like the time, they say. - Henry's Cat.
 
Thank you Karver.
The funny thing is that even the technical support staff of the company that hosts us didn't know at was installed on the server.
Have a nice day.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top