如何按日期自动发送电子邮件


how to send Email by date automatic

我有这个源代码,它运行得很好,但我想按日期发送电子邮件如

(Today date == date from DB)
{
    Code send 
}

如何自动发送,我不想重新加载页面。

我的源代码:

  `<`?php
include "classes/class.phpmailer.php"; // include the class name
$mail = new PHPMailer(); // create a new object
$mail->IsSMTP(); // enable SMTP
$mail->SMTPDebug = 1; // debugging: 1 = errors and messages, 2 = messages only
$mail->SMTPAuth = true; // authentication enabled
$mail->SMTPSecure = 'ssl'; // secure transfer enabled REQUIRED for GMail
$mail->Host = "smtp.gmail.com";
$mail->Port = 465; // or 587
$mail->IsHTML(true);
$mail->Username = "gmailusername@gmail.com";
$mail->Password = "**********";
$mail->SetFrom("anyemail@gmail.com");
$mail->Subject = "Your Gmail SMTP Mail";
$mail->Body = "<b>Hi</b>";
$mail->AddAddress("anyaddrees@domain.com");
 if(!$mail->Send()){
    echo "Mailer Error: " . $mail->ErrorInfo;
}
else{
    echo "Message has been sent";
}
?>

您可以在windows上使用任务调度程序,也可以在linux上使用cronjob。正如"简"在评论中所说,你能提供更多信息吗。