我正在使用PHP
和MySQL
。我正在尝试发送邮件,但它无法正常工作。我想检查两个日期并在特定日期发送邮件。
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';
}
}}
答案 0 :(得分:1)
好的,请检查以下解决方案: -
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)
{