我正在开发一个自动监视系统.我已经制作了一个具有MySQL数据库的.NET应用程序.为此,我开发了一个普通的ADMIN面板,管理员可以在其中登录并从数据库中触发的各种查询中获取必要的报告.面板中还有一个摘要报告",只是每周的摘要.现在我想要的是,我希望此报告(所有文本)在7天的时间内自动发送到某些电子邮件"xxxxx@xxx".以前,我曾使用一些PHP脚本在单击提交"按钮时发送电子邮件.像下面的那个.
I am working on an automatic monitoring system. I have made a .NET application which have MySQL database. For this I developed a normal ADMIN Panel where admin can log in and get necessary reports coming from various queries fired on the database. There is also a "summary Report" in the panel which is just the rough weekly summary. Now What I want is, I want this report (all text) to get sent automatically to some email "xxxxx@xxx" with a seven day period. I have used some PHP scripts previously to send email on submit button click. Like the one below.
<?php if(isset($_POST['isPost'])) { $header="From:".$_POST['customer_mail']."\r\nName:".$_POST['name']."\r\nCity:".$_PO ST['city']; $subject = $_POST['title']; $message="From:$_POST[customer_mail]\r\nName:$_POST[name]\r\nPhone:$_POST[city]\r\n \r\n\r\n\r\n".$_POST['details']; $to = 'xxxxxxxxx@xxx'; $send_contact=mail($to,$subject,$message,$header); if($send_contact) { echo "<h6 style='text-align:center;color:green'>Sent Successfully</h6>"; } else { echo "<h6 style='color:red'>Error sending e-mail'</h6>"; } } ?>这是正常的邮件发送脚本,可以正常工作.但是出于上述目的,有人可以帮助我定期自动设置此操作,也可以为我指明正确的操作方法.我已经谷歌搜索这样的PHP脚本,但没有满意的结果. 〜问候
this is normal mail sending script which works fine. But for the above purpose I want, Can anyone help me to set this action periodically and automatically or point me in the right direction on how to do this. I have googled for such php script but no satisfied results. ~ Regards
推荐答案您可以使用cronjobs进行此操作. 一个长期运行的过程,可以在给定的时间/日期/间隔执行命令.
You can do this with cronjobs. A long running process which executes commands at given times / dates / intervals.
根据您使用的系统,有不同的方法.
Depending on what system you are, there are different methods.
如果您将脚本放在网络服务器上,则有人正在为您运行/Webhost服务
要求系统管理员使用cronjob运行脚本.或搜索任何帮助文档(如果您可以在任何管理面板中自行设置).向您的网站托管服务商/系统管理员咨询以获取更多信息.
Ask the system administrator to run the script with a cronjob. Or search for any help documentation if you can setup this yourself in any admin-panel. Ask your webhoster /system admin for more information.
如果脚本在您自己的本地计算机上:
UNIX
尝试阅读有关如何运行php脚本或任何脚本的 crontab 的信息对于这个问题.
Try reading about crontab on how to run the php script, or any script for that matter.
例如,键入crontab -e并在crontab中添加以下行,cronjob将每小时运行一次脚本:
For example type crontab -e and add the line below in your crontab, the cronjob will run your script every hour:
00 * * * * /usr/local/bin/php /home/Low-pointer/myscript.php如果您想间隔学习,这里有一些更多信息
Windows
如果您使用Windows,则可以使用预定的任务来运行php命令.
If you use Windows you can use scheduled tasks to run the php command.
例如,将以下命令添加到调度程序:C:\wamp\bin\php\php.exe -f C:\wamp\www\my_script.php
For example add the following command to the scheduler: C:\wamp\bin\php\php.exe -f C:\wamp\www\my_script.php
您还可以使用Web Cron服务( Google it )这些在线服务会在指定的时间运行页面(例如,在您的网络服务器上).免费或付费.
You can also use web cron services (Google it) these are online services which run a page (for example on your webserver) on designated times. For free or paid.
更多推荐
通过php脚本定期发送电子邮件
发布评论