0

I would like to enable all members of an organic group to subscribe to a reminder, that sends an e-mail depending on a date field. To be more specific: The group has a group content with a date field. Now I would like a mail being sent a specific time before this date becomes actual. Would would the best way to do this?

2 Answers 2

1

When it comes to right on schedule or specific time, you need to have crontab on server. Role of cron tab will be none other than calling your cron.php file which in turn allows all modules to set the cron. But this is half of the process since with core drupal cron process you can not have much control on setting schedule time, so you can use elysia cron module to extend drupal core cron.This was cron part

Now inorder to trigger email you can implement hook_cronapi() as an example,

function mymodule_cron_cronapi($op, $job = NULL) {  

  $items['send_email'] = array(
    'description' => 'Send email to group users',
    'rule' => '0 * * * *', // Every Hour at **:00
    'callback' => 'mymodule_email_group_callback',
  );
  return $items;
}

cron callback

function mymodule_email_group_callback() {
  // load all group content from that content type.
  // loop through all nodes check date
  // if true
  // get all subscribers and loop through them
  // send email
}
0

Off the top of my head I think Maestro can do this with a Batch Task or a Batch Function Task. In drupal typically Cron is setup to run periodically, say every hour or every 15 minutes.

If you truly want a specific time for these notifications to go out you need a (cron) task that runs every minute for example and examines if there are notifications to send now as time passes.

Alternatively you could use some sort of Job/Worker queue that Drupal talks to.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.