简体   繁体   English

如何在经过的时间达到特定时间后自动发送电子邮件?

[英]How to send emails when elapsed time reaches specific hours automatically?

I want to send emails automatically to a particular group (outlook) when my elapsed time (in database) reaches 3 hours, 6 hours & 12 hours. 当我的经过时间(在数据库中)达到3个小时,6个小时和12个小时时,我想自动将电子邮件发送到特定的小组(外部)。 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!. 我更喜欢用代码而不是cron来做。.希望大家都能提供帮助!

Thanks in advance!! 提前致谢!!

<?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");
}?>

Better you schedule email using cron job. 最好使用cron作业计划电子邮件。 This is probably the best way for sending emails. 这可能是发送电子邮件的最佳方法。

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何在特定的日期或时间在php中自动发送电子邮件? - how to send emails automatically on certain day or time in php? 如何在用户执行特定操作时向用户朋友发送电子邮件? - How to send emails to a users friends when the user takes a specific action? 如何在特定时间之前自动将邮件发送给相应的用户? - How to send the mail automatically to respective user before a specific time? 如何通过PHP一次发送许多电子邮件 - how to send many emails in one time by php 如何计算从该日期时间戳记中经过的时间,并在适当的分钟,小时或几天内将其返回 - How to work out time elapsed from this datetime stamp and return it in either minutes, hours or days as appropriate 如何从网站自动发送非交易电子邮件 - How to send non-transactional emails automatically from website 计算经过php的时间-跨越24小时 - Calculate time elapsed in php - spans over 24 hours 如何将电子邮件发送到在while循环中生成的具有特定行信息的电子邮件? - How to send email to emails generated in while loop with specific row information? Laravel Mail:如何按特定域发送批处理电子邮件 - Laravel Mail: how to send batch emails per specific domain 如何使用php在较短的时间内发送批量电子邮件? - How to send bulk emails in less time using php?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM