Jump to content

email notification everyday


abs0lut

Recommended Posts

<?php
function diffDates($date1,$date2) {
	$date1_array = explode("-",$date1);
	$date2_array = explode("-",$date2);
	$tstamp1 =
		mktime(0,0,0,$date1_array[1],$date1_array[2],$date1_array[0]);
	$tstamp2 =
		mktime(0,0,0,$date2_array[1],$date2_array[2],$date2_array[0]);
	$diff= ($tstamp2 - $tstamp1)/86400;

	return round($diff,0);
}		
diffDates($date01,$date02);  
?>

the computer will send an email containing the computed difference everyday before the date that is stored in database..

the computer will not send if the date today is equal or greater than the date that is stored in database..

could you please help me...

HERE A QUICK EXAMPLE TO SEND A EMAIL EVERYDAY VIA DATE...

 

<?php

$a=array("20080514"); // DATABASE DATE........

$new_date = date("Ymd"); // TODAYS DATE VIA THE DATE FUNCTION..  

$old_date=implode(' ',$a);

if($new_date > $old_date){

$mess="The date of $old_date is less then new date $new_date so each day ill get an email!";	
$to = '[email protected]';
$subject = 'The date!';
$message = $mess;
$headers = "From: [email protected]\r\n" .
        'X-Mailer: PHP/' . phpversion() . "\r\n" .
        "MIME-Version: 1.0\r\n" .
        "Content-Type: text/html; charset=utf-8\r\n" .
        "Content-Transfer-Encoding: 8bit\r\n\r\n";

// Send
if(mail($to, $subject, $message, $headers)){

echo"Mail was sent!";
}else{
echo "Mail was not sent!";
}
}
?>

HERE A QUICK EXAMPLE TO SEND A EMAIL EVERYDAY VIA DATE...

 

<?php

$a=array("20080514"); // DATABASE DATE........

$new_date = date("Ymd"); // TODAYS DATE VIA THE DATE FUNCTION..  

$old_date=implode(' ',$a);

if($new_date > $old_date){

$mess="The date of $old_date is less then new date $new_date so each day ill get an email!";	
$to = '[email protected]';
$subject = 'The date!';
$message = $mess;
$headers = "From: [email protected]\r\n" .
        'X-Mailer: PHP/' . phpversion() . "\r\n" .
        "MIME-Version: 1.0\r\n" .
        "Content-Type: text/html; charset=utf-8\r\n" .
        "Content-Transfer-Encoding: 8bit\r\n\r\n";

// Send
if(mail($to, $subject, $message, $headers)){

echo"Mail was sent!";
}else{
echo "Mail was not sent!";
}
}
?>

this will send an email everyday without using cron jobs??

or do I need to run manually the file??

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.