I know how to select the members who did not post for every topic.
I need to send an email every 24 hours to the members who did not post for every topic. Could you please help me?

Dani AI

Generated

A practical, production-friendly pattern that builds on 's hit-trigger idea and 's DB note is: keep a tiny, idempotent worker that processes a durable queue and trigger it from normal page traffic with a non-blocking call. is correct that system cron is simplest where available; when cron is not an option, the following minimizes duplicate sends, avoids long web requests, and survives restarts.

Suggested flow (minimal changes to an existing site):

  • Track per-topic/per-user last-sent time in a table (so each recipient is skipped if already emailed for this interval).
  • When a scheduled run is due, build a work queue (rows listing topic_id, user_id) and mark the run as "started".
  • Process the queue in small batches (e.g., 50–200) from a CLI-style worker; after each batch update last_sent_at for processed rows.
  • Trigger the worker from a high-traffic page using a fire-and-forget HTTP request so page response is not delayed.

Example non-blocking trigger (placed in a shared include):

<?php
// quick check to avoid frequent firing
if (time() - get_option('daily_mail_last_trigger', 0) > 23*3600) {
  set_option('daily_mail_last_trigger', time());
  // fire-and-forget internal request
  $host = $_SERVER['HTTP_HOST'];
  $fp = @fsockopen($host, 80, $errno, $errstr, 1);
  if ($fp) {
    fwrite($fp, "GET /task/daily_mail_worker.php HTTP/1.1\r\nHost: $host\r\nConnection: Close\r\n\r\n");
    fclose($fp);
  }
}
?>

Operational notes: use a DB lock (MySQL GET_LOCK or an "in_progress" flag) to prevent concurrent runs; keep batch sizes small and track retries for failures; log send results and respect unsubscribe/suppression lists; use an SMTP provider and throttle according to provider limits. If reliability is required and cron is unavailable, consider an external HTTP-scheduler (simple ping service) to call the worker endpoint once a day.

Recommended Answers

All 4 Replies

Why can't you use cron?

without cron the only way would be from a page that is accessed from the web. You would probably have to keep a log of successful mail events and use an if statement in one of your more visited pages. In the if statement you would use the date() function and determine if the current time is past a specific time of day and that the current date is not found in the log. If that is the case, send the emails and write to log.

thanks for your suggestion ,i m also searching for the same
...i got it how to use that .
i just want to add a line that you can use database to store your last mail sent time or date

nice post......

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.