Reputation: 2623
I have two file 'mail.php' and 'cron.php' . 'mail.php' receives email address from a source continuously . 'cron.php' will send email to those address at the next hour of receiving hour .If email address is received at 5.45 email will be sent at 6.00 . My idea is to run cron.php every hour which will get email addresses and their receiving time form session variable. But how can I synchronise this two file ?? Is it possible to access session variable simultaneously by this two file ?? that means mail.php will write data and after sending mail cron.php will delete those data from session.
Thanks in advance.
Upvotes: 1
Views: 1702
Reputation: 37711
Can't you just make a function for sending emails (turn mail.php into a function?) and call it with cron.php?
Upvotes: 1
Reputation: 10613
You'd have to post some code up. I dont really understand what you mean. The first part of your weustion leads me too believe that you have something setup already, whereas the latter half doesn't.
Basically what you need to do, is have mail.php (the one that gets the email addresses from wherever there coming) and store those somewhere (database or plain text file maybe). Then every hour, run the cron, grab the emails, do whatever you need to do then either elete thos eemails, archive them in another place if you need to keep them, or if your using a database you could use an "email_sent" column and set it to 1 once the emails have been sent.
Upvotes: 3
Reputation: 3721
Answer about session and CRON here. can php cron jobs access session variables/cookies?
If I were you I'll save the email addresses in database or a text file. And then delete them after executed.
Upvotes: 2