简体   繁体   中英

php send mail using cron jobs

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.

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.

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.

您能否仅制作一个用于发送电子邮件的功能(将mail.php转换为功能?)并使用cron.php进行调用?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM