问题描述
php脚本使用windows服务发送电子邮件作为网站托管在windows机器。我正在寻找一个不涉及cron工作的解决方案。我希望用户安排时间,Windows服务应该在计划的时间执行我的PHP电子邮件脚本,以便电子邮件在计划的用户时间发送。我想在php中编写整个代码。
I want to schedule my php script which sends emails using windows services as the website is hosted in windows machine. I am looking for a solution which does not involve cron jobs. I want users to schedule a time and the windows service should execute my php email script on the scheduled time so that emails are sent on the scheduled user time. I want to write the entire code in php.
推荐答案
您无权访问Windows机器上的cron作业;但是,没有一个办法,没有窗口的调度程序,除非你有一个非常活跃的网站,有人总是在它,然后你可以检查和运行每个页面加载或类似的东西。否则,我会写一个脚本,当电子邮件被假定发送时,它检查DB - 并拉取假设要运行的分钟(或半小时,或任何间隔,您允许用户从中选择)并通过Windows调度程序每分钟/间隔调度运行该脚本。
You don't have access to cron jobs on a Windows Machine ;) But, there isn't a way to do that without the window's scheduler unless you have a VERY active site where someone is always on it, and then you can check and run on each page load or something similar. Otherwise, I would write a script that checks the DB for when emails are suppose to be sent - and pull the ones that are suppose to be ran that minute (or half-hour, or whatever intervals you allow your users to select from), and schedule run that script every minute/interval via the windows scheduler.
这篇关于windows服务在php中执行计划电子邮件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!