how to send a letter to mail in php, if the mail is indicated in the human table in the e_mail column, but the letter should be sent on the condition that it expires, if there is such a condition

'rowOptions'=>function($model){ $dun = "success"; if( date("Ymd", strtotime($model->data_okon. "-10 days")) <= date("Ymd") ){ $dun = 'warning'; } if( date("Ymd", strtotime($model->data_okon. "-5 days")) <= date("Ymd") ){ $dun = 'danger'; } return [ 'class' => $dun, ]; }, 
  • Related question: stackoverflow.com/questions/721338/… - Byulent
  • one
    Well, get user $to mail, text $message (or several), heading $subject (or several) and thrust mail($to,$subject,$message); in your if condition - Dan the Hat

1 answer 1

Something like:

 $to = ''; // засовываете сюда почту пользователя $subj1 = 'Все хорошо'; $subj2 = 'Все не очень хорошо'; $subj3 = 'Все совсем не хорошо'; $mess1 = 'На улице - солнце'; $mess2 = 'На улице - дождь'; $mess3 = 'На улице - ураган и маньяки'; 'rowOptions'=>function($model){ $dun = "success"; if ( date("Ymd", strtotime($model->data_okon. "-10 days")) <= date("Ymd") ){ $dun = 'warning'; mail($to,$subj2,$mess2); } if( date("Ymd", strtotime($model->data_okon. "-5 days")) <= date("Ymd") ){ $dun = 'danger'; } return [ 'class' => $dun, mail($to,$subj3,$mess3); ]; },