I have been using Rules for a number of functions on my site and I have to say, it's one of the most useful modules. Unfortunately, I don't seem to be able to get the scheduling function to work correctly, despite working on it for about a week, and I'm hoping someone can point out what I'm doing wrong.

I used these tutorials:
http://drupal.org/node/517674
http://drupal.org/node/520012

as a guide to try to send out an email to an applicant based on the "to date" field of a "Dates available" span. Here's the procedure I used to set this up yesterday:

1) Created content - a teacher application with "from" and "to" date fields for "Dates available" span.

2) Created a few dummy applications for testing with the "to" date set to today.

3) Created a ruleset: "Send email to teacher applicant {ruleset}".
- Data type: Content; Label: Content {argument}; Machine readable name: send_email_to_teach_app__content

4) Added a new rule to this ruleset: Send email to teacher applicant {rule}.

5) Added an action: System|Send a mail to an arbitrary mail address.
- Populated Recipient, Subject and Message fields.

6) Added a triggered rule: Schedule "Send email to teacher applicant {ruleset}";
Event: After saving new content

7) Added a condition: Content has type Teacher Application; Content: created content

8) Added an action: Rule scheduler: Schedule "Send email to teacher applicant {ruleset}"
- Content {argument}: created content
- Identifier: node [node:nid]
- Scheduled evaluation date: [node:field_date_available-to-date]

9) Cloned the above for updated content.
- Added a condition "Numeric comparison":
[node:field_date_available-to-date] greater than echo time();

I saw that there were 3 items matching the three dummy apps scheduled yesterday in admin/rules/rule_sets/scheduling, and I rubbed my little paws together with glee. Imagine my disappointment when no emails were waiting for me today.

Any idea what went wrong? Thanks for any light you can shed on my bewilderment.

Comments

mjstone323’s picture

Just found this thread: http://drupal.org/node/486168

which seems to be about a similar problem... Is anyone still working on this? I would really appreciate some suggestions, since I need to use tokens in my recipient field and email body.

mjstone323’s picture

I should add that there is nothing scheduled anymore - so the actions must have run. I am completely confused.

Itangalo’s picture

Status: Active » Postponed (maintainer needs more info)

It should be possible to check the Drupal log to see if any e-mails have been sent, and if so to which address. Check out the reports section, and see what you can find. It is possible that this is a problem on the server's side -- but it could also be that the e-mail address for some reason can't be fetched. (It could of course also be spam filters in the way, but I guess you have already checked that.)

It should be noted that cron must run in order to carry out scheduled tasks, but if the tasks are removed from the list cron should be running as it should.

Good luck,
//Johan Falk
I'm a part of the Rules Issue Squad, helping out in the issue queue. You can join, too!

mjstone323’s picture

Thanks very much for the reply - I will check this out.

mjstone323’s picture

Okay - it's working - sort of! It's sending the email out immediately after the content is created, not based on the CCK date field. I'll have to fiddle with this I guess.

mjstone323’s picture

I've got it working! But not exactly how I want to... I used a GMT timestamp (e.g. echo time() + 86400 * 1; ) and it's scheduling it - I expect to see an email when I get back on Monday.

It also works with a token for a date field, but what I'd really like to do is use a token plus an strtotime() function, as in [node:field_date_available-from-date] +1 day. Unfortunately this schedules an empty date. I need to do this in case the date in the field changes (which is what is hoped for) - I always want an email to go out a set time after the date in the field. Not sure how this is going to work.

I will research this, but I would be grateful if someone could point me in the right direction, if this is possible.

mikedotexe’s picture

I have the exact same problem as mjstone323, I'm wanting to send out a reminder email the DAY BEFORE an event, and the DAY AFTER.
Using tokens I cannot seem to manipulate the time.

I tried entering

<?php echo [node:field_er_event_date-timestamp] - 86400 * 1; ?>

with no luck.

mikedotexe’s picture

In response to #6,

I was able to get this working by adding an extra date field, and then "hiding it" using a form alter. Here's a link to my solution, that sends it out one day before and one day after the CCK value.
All you would do is change the "+1" part of the code found here.

klausi’s picture

Version: 6.x-1.x-dev » 7.x-2.x-dev
Component: Scheduler » Rules Engine
Category: support » bug
Priority: Normal » Critical
Status: Postponed (maintainer needs more info) » Closed (cannot reproduce)

Closed since no further information has been provided. Reopen if still an issue.

jomarocas’s picture

Component: Rules Engine » Rules Core

i follow his ansswer and worked for me

need install rules_schedule, cck, tokens

http://drupal.stackexchange.com/questions/138076/create-an-e-mail-remind...