これにcronジョブを使用して、ユーザーに自己登録があるかどうかを確認するために時間間隔を追加することができます。ユーザーが自己登録を持っていて、メールを送信するための別の関数を呼び出す場合。
function checkuser(){
$total_time = 0;
$start_time = microtime(true);
while($total_time < 60)//run while less than a minute
{
checkFunction(); //DoSomething;
sleep(20); //wait amount in seconds
$total_time = microtime(true) - $start_time ;
}
}
function checkFunction(){
//check user self enrollment here add into some variable
// check if it is true than
if($check == true){
$to = '[email protected]';
$subject = 'the subject';
$message = 'hello';
$headers = 'From: [email protected]' . "\r\n" .
'Reply-To: [email protected]' . "\r\n" .
'X-Mailer: PHP/' . phpversion();
mail($to, $subject, $message, $headers);
}
}