问题描述
我想安排我的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作业;但是,没有窗口的调度程序没有办法,除非你有一个非常活跃的站点,有人总是在它,然后你可以检查和运行在每个页面加载或类似的东西。否则,我会写一个脚本,检查数据库是否有电子邮件被发送 - 并且拉出那些假定要运行那一分钟(或半小时,或者允许你的用户选择的任何间隔)的脚本,并且计划通过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执行计划电子邮件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!