mirror of https://github.com/itflow-org/itflow
Allow to set an optional queue time in bulk mail, update cron_mail_queue.php to only send mail after its queued_at date and time
This commit is contained in:
parent
62fb73875b
commit
ad1ec7d338
|
|
@ -48,6 +48,15 @@ $sql = mysqli_query($mysqli, "SELECT * FROM contacts
|
|||
<textarea class="form-control tinymce" name="body" placeholder="Type an email in here"></textarea>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<div class="input-group">
|
||||
<div class="input-group-prepend">
|
||||
<span class="input-group-text"><i class="fa fa-fw fa-calendar"></i></span>
|
||||
</div>
|
||||
<input type="datetime-local" class="form-control" name="queued_at">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="col">
|
||||
|
|
|
|||
|
|
@ -61,7 +61,7 @@ file_put_contents($lock_file_path, "Locked");
|
|||
|
||||
// Get Mail Queue that has status of Queued and send it to the function sendSingleEmail() located in functions.php
|
||||
|
||||
$sql_queue = mysqli_query($mysqli, "SELECT * FROM email_queue WHERE email_status = 0");
|
||||
$sql_queue = mysqli_query($mysqli, "SELECT * FROM email_queue WHERE email_status = 0 AND email_queued_at <= NOW()");
|
||||
|
||||
if (mysqli_num_rows($sql_queue) > 0) {
|
||||
while ($row = mysqli_fetch_array($sql_queue)) {
|
||||
|
|
|
|||
|
|
@ -938,8 +938,8 @@ function addToMailQueue($mysqli, $data) {
|
|||
$body = strval($email['body']);
|
||||
|
||||
// Check if 'email_queued_at' is set and not empty
|
||||
if (isset($email['email_queued_at']) && !empty($email['email_queued_at'])) {
|
||||
$queued_at = $email['email_queued_at'];
|
||||
if (isset($email['queued_at']) && !empty($email['queued_at'])) {
|
||||
$queued_at = $email['queued_at'];
|
||||
} else {
|
||||
// Use the current date and time if 'email_queued_at' is not set or empty
|
||||
$queued_at = date('Y-m-d H:i:s');
|
||||
|
|
|
|||
|
|
@ -12,6 +12,7 @@ if (isset($_POST['send_bulk_mail_now'])) {
|
|||
$mail_from_name = sanitizeInput($_POST['mail_from_name']);
|
||||
$subject = sanitizeInput($_POST['subject']);
|
||||
$body = mysqli_escape_string($mysqli, $_POST['body']);
|
||||
$queued_at = sanitizeInput($_POST['queued_at']);
|
||||
|
||||
// Add Emails
|
||||
foreach($_POST['contact'] as $contact_id) {
|
||||
|
|
@ -30,7 +31,8 @@ if (isset($_POST['send_bulk_mail_now'])) {
|
|||
'recipient' => $contact_email,
|
||||
'recipient_name' => $contact_name,
|
||||
'subject' => $subject,
|
||||
'body' => $body
|
||||
'body' => $body,
|
||||
'queued_at' => $queued_at
|
||||
];
|
||||
}
|
||||
addToMailQueue($mysqli, $data);
|
||||
|
|
|
|||
Loading…
Reference in New Issue