当经过的时间自动达到特定时间时如何发送电子邮件? [英] How to send emails when elapsed time reaches specific hours automatically?

查看:34
本文介绍了当经过的时间自动达到特定时间时如何发送电子邮件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我的经过时间(在数据库中)达到 3 小时、6 小时和; 时,我想自动向特定组(outlook)发送电子邮件.12小时.我搜索了很多,但我找不到答案.下面是我的代码,用于显示到目前为止所用的时间.我更喜欢用代码而不是 cron 工作.. 希望大家能帮忙!

I want to send emails automatically to a particular group (outlook) when my elapsed time (in database) reaches 3 hours, 6 hours & 12 hours. I searched a lot, but i couldn't find an answer. Below is my coding to display the elapsed time so far. I prefer doing it in code than cron job.. Hope you all can help!.

提前致谢!!

<?php
$i = 1;
while ($csv=mysqli_fetch_assoc($records)){
$A=$csv['Name'];
$B=$csv['SRNumber'];
$C=$csv['ServiceImpact'];
$D=$csv['CustomerRefNo'];
$E=$csv['ReportedDateAndTime'];
$K=['ElapsedTime'];
?>

<tr>
<td><?php echo $A; ?></td>
<td><?php echo $B; ?></td>
<td><?php echo $C; ?></td>
<td><?php echo $D; ?></td>
<td><?php echo $E; ?></td>
<td><?php echo $K; ?></td>

<td><?php
date_default_timezone_set('Asia/Colombo');
$the_time = date('H:i');
$sql="SELECT ReportedDateAndTime FROM csv";
$result=$conn->query($sql);
while ($row = $result->fetch_assoc()){ 
$new_time=$row['ReportedDateAndTime'];
$datetime1 = new DateTime($the_time);
$datetime2 = new DateTime($new_time);
$interval = $datetime2->diff($datetime1);
$hours=$interval->format('%h');
$minutes= $interval->format('%i');
$seconds= $interval->format('%s');
echo $hours." Hours  ".$minutes."  Minutes ".$seconds." Seconnds</br></br>";
} ?>
</td>
<td>
<a href="Escalation_Display.php?delete=<?php echo $B?>" onclick="return confirm('SR Resolved?');">Archive</a>
</td>
</tr>

<?php
$i++;}
if(isset($_GET['delete'])){
$delete_id = $_GET['delete'];
mysqli_query($conn, "DELETE FROM csv WHERE SRNumber = '$delete_id'");
header("location:Escalation_Display.php");
}?>

推荐答案

使用 cron 作业更好地安排电子邮件.这可能是发送电子邮件的最佳方式.

Better you schedule email using cron job. This is probably the best way for sending emails.

http://docs.phplist.com/CronJobExamples.html

这篇关于当经过的时间自动达到特定时间时如何发送电子邮件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆