0

I am not sure where to begin setting up an automatic recurring email reminder app. I currently have a form that inserts data into a msyql database.

<form method="post" action="save.php">

<p>
    <label for="name">Full Name</label><br />
    <input type="text" name="name" data-h5-errorid="error-name" required />
    <span id="error-name" class="error">Please enter a full name</span>
</p>

<p>
    <label for="address">Address (Street Address Only)</label><br />
    <input type="text" name="address" data-h5-errorid="error-address" required />
    <span id="error-address" class="error">Please enter an address</span>
</p>

<p>
    <label for="email">Email</label><br />
    <input type="email" name="email" data-h5-errorid="error-email" required />
    <span id="error-email" class="error">Please enter a valid email address</span>
</p>

<p>
    <label for="date">Date of Service</label><br />
    <input id="date" type="text" data-h5-errorid="error-service" name="date" required />
    <span id="error-service" class="error">Please choose a date</span>
</p>

<p>
    <label for="reminder">Reminder</label><br />
    <select name="reminder">
        <option value="1">30 Days</option>
        <option value="2">60 Days</option>
        <option value="3">Semiannual</option>
        <option value="4">Annual</option>
    </select>
</p>

<p>
    <label for="notes">Notes on Service</label><br />
    <textarea name="notes" rows="15"></textarea>
</p>

<p>
    <input type="submit" value="Submit" />
</p>

</form>

I am storing all fields in the database and have that working properly using http://medoo.in/. How do I go about creating a PHP script to send a recurring email based on the Service Date and the selected Reminder (every 30 days, 60 days, semianually, annually)? I was thinking of using PHP mailer to send the actual emails and running a daily cron job.

4

2 回答 2

0

只需编写一段代码来为您的 cronjob 配置时间间隔。(使用从您的表单中收到的数据。)如果您使用 DirectAdmin,只需按照Dušan Radojević 的Cronjob 执行 PHP 脚本回答。然后它几乎完成了!

于 2013-09-28T21:13:01.870 回答
0
<?php

//first start with a MySQL query to gather the rows to send an email
//this is for 30 days but you can adjust the numbers for each case

$30_day_query = "SELECT * FROM users WHERE reminder = 1 AND date
BETWEEN DATE_SUB(NOW(),INTERVAL 29 DAY) AND DATE_SUB(NOW(), INTERVAL 30 DAY)";

$execute = mysql_query($30_day_query);

while($row = mysql_fetch_array($execute)){
//get info of user
$name = $row['name'];
$email = $row['email'];

//send the email however you want
}
//repeat for the rest of the reminder options
?>

如果您在每日 cron 作业中运行它,您将不会发送重复的电子邮件。

于 2013-09-28T21:12:03.077 回答