gpt4 book ai didi

php - 如何在特定日期用 PHP 和 MySQL 发送邮件?

转载 作者:可可西里 更新时间:2023-11-01 08:47:22 25 4
gpt4 key购买 nike

我正在使用 PHPMySQL。我正在尝试发送邮件,但无法正常工作。我想检查两个日期并在特定日期发送邮件。

   if (isset($_POST['mail_sub']))
{
$selectDate = "select * from insurance_data";
$querydate = mysql_query($selectDate) or die (mysql_error());
while ($roedate = mysql_fetch_array($querydate))
{
$date1 = $roedate['duedate'];
$date=date('Y-m-d',strtotime($date1.' -3 days'));
echo '<br>';
echo $date;
echo $today = date('Y-m-d');

if ($date==$today)
{
$to = "2606ankit@gmail.com"; //put email address on which mail send
$subject = "Query Mail"; //Put subject of mail here
$from = "2606ankit@gmail.com"; //put email address from
//email body start
$body .= "<label class='font_Style'>Alert</label>";
// Always set content-type when sending HTML email

$headers = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=UTF-8' . "\r\n";

// More headers
$headers .= 'From: '.$from. "\r\n";

//if you need to send cc mail then uncomment below line and change email address
//$headers .= 'Cc: myboss@example.com' . "\r\n";

mail($to,$subject,$body,$headers);

//echo 'asdfasdf';
}
else
{
echo 'nahi';
}

}}

最佳答案

好的,请检查以下解决方案:--

 if (isset($_POST['mail_sub']))
{
$selectDate = "select * from insurance_data";
$querydate = mysql_query($selectDate) or die (mysql_error());
while ($roedate = mysql_fetch_array($querydate))
{
$date1 = $roedate['duedate'];
$date=strtotime($date1.' -3 days'); // Remove the date
echo '<br>';
echo $date;
echo $today = strtotime(date('Y-m-d')); // User strtotime

if ($date==$today)
{

关于php - 如何在特定日期用 PHP 和 MySQL 发送邮件?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24647797/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com