我创建了send_bday_email.php,它会在客户生日前2周发送生日邮件。
<?php
$today = date('Y-m-d');
$todayMD = date('m-d');
include_once "../../mysqli_connect.php";
$sql= mysqli_query($dbc, "SELECT * FROM Customer_Info");
$mail_body = '';
while ($row= mysqli_fetch_array($sql)) {
$id = $row["id"];
$email = $row["email"];
$birthday = $row['birthday'];
$bday = new DateTime($birthday);
$bday->sub(new DateInterval('P14D'));
$twoWeekbday = $bday->format('m-d');
if ($todayMD==$twoWeekbday) {
if(empty($row["firstName"])){
$name = 'Customer';
} else {
$name = $row["firstName"];
}
$mail_body = file_get_contents('../forms/bday_email_form.html');
}
}
这是我提前两周的代码部分,如果客户的前两周等于今天发送生日邮件。
如果我每天使用cron job运行此代码,它会完美地发送电子邮件吗?
在我与客户实际测试之前,我想确定一下。