In my project i need to send an email in php before 2 days of my account expiry date. the date is stored in mysql db, how to send. Email shoul be send automatically from server.
<?php
include("config.php");
$select_date=mysql_query("SELECT `date` FROM `app_users` WHERE `user_id`=1");
$fetch_date=mysql_fetch_assoc($select_date);
$date=$fetch_date['date'];
$now = date("Y-m-d");
$cur_date=strtotime($now);
$your_date = strtotime($date);
$datediff = $your_date-$cur_date;
$days=floor($datediff/(60*60*24));
$email="nisha.gksh@gmail.com";
$subject="Account Expiry";
$message="Your account expires in 2 days";
$headers = "From: info@datesreminder.com" . "\r\n";
if($days==2)
{
mail($email,$subject,$message,$headers);
}
?>