Jump to content

email notification everyday


abs0lut

Recommended Posts

the computer will subtract todays date from the date that is stored in database

then, the computer will send an email everyday before the date that is stored in database..

example

its only 3 days and the poll will be closed

 

please help...

 

 

Link to comment
Share on other sites

<?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...

Link to comment
Share on other sites

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 = 'bob@barnyard.com';
$subject = 'The date!';
$message = $mess;
$headers = "From: server@barnyard.com\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!";
}
}
?>

Link to comment
Share on other sites

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 = 'bob@barnyard.com';
$subject = 'The date!';
$message = $mess;
$headers = "From: server@barnyard.com\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??

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.