0

I have been scratching my head on this one for awhile. I need to send out an email on certain days after someone registers with my site.

Day of registration (Set up) 1 month 3 months 6 months 1 year and every year after

Right now an automatic email goes out the day of registration. That works fine but now I need one after 1 month and so on. The months I think I understand. It is just comparing the date to the registered on date, and then the yearly message I have no idea. I am still learning how to do this so any help would be great thanks!

//get status of email queue
$q_lock = getLockStatus($conexao, 5);

//if email queue is locked, exit the script
if($q_lock)
{
exit();
}
//if email queue is not locked, lock it now and continue
else
{
setLockStatus($conexao, 5, 1);
}

$aryQueue = getMemberemails($conexao);
$date = date("Y-m-d");
$current_year = date("Y");
//echo '<pre>', print_r($aryQueue, true), '</pre>';

foreach($aryQueue as $e)
{
$email_id = $e["id"];
$full_name = $e["full_name"];
$to_name = $e["first_name"];
$email= $e["email"];
$member_id = $e["member_id"];
$registered_on = $e["registered_on"];
$yearly_message = date('Y-m-d', strtotime("$registered_on + 1 year"));
$oneYearOn = date('Y-m-d',strtotime(date("Y-m-d", mktime()) . " + 365 
day"));



if( $date == $yearly_message){
  • 1
    You should probably format your code a bit better, by indenting the lines - that would make it *a lot* easier to read. That being said, what you're looking for might be a CRON job - run it every day, and find the users that have been registered for exactly 1 month, 3 months, 6 months, or whole years. – Qirel May 15 '17 at 14:52
  • Possible duplicate: http://stackoverflow.com/questions/24319734/automatic-mail-sending-on-specific-dates-in-php – lu5er May 15 '17 at 14:55
  • Sorry I am new to this, I copied and pasted from my code (formatted correctly) and it got messed up in the paste.) I figured it would be a cron job sorry I forgot to mention that. So your saying compare the date see if they have been registered for over x and then take those selected users and send? Thanks again any help would be great! – PandaCoffee May 15 '17 at 14:55
  • You need to learn how to use CRON. – Jay Blanchard May 15 '17 at 15:15

0 Answers0