I'm creating some CiviMail mailings using the API. Sometimes my mailings get created and scheduled, but when they execute, they are marked as "completed" but show as having
Intended Recipients: 0 in the mailing report, even though the recipient group is correctly populated:
When I create the exact mailing manually through the GUI, I get the proper intended recipients and the email is sent.
The code I'm using can be found in my CiviMail Tools Drupal module that provides rules integration for CiviMail using the CiviCRM API.
So, I have a rule component set up that creates a CiviMail mailing when a node is published. If I execute or schedule (rules scheduler) the rule component manually, the mailing gets intended recipients. However, if the component is scheduled automatically by an event trigger, then the CiviMail mailing is created and scheduled, but has
Intended Recipients: 0 as in the above screenshot.
Any idea what might cause this? Again, it only happens when Drupal schedules my rule component based on an event trigger. If I schedule it manually, it all works. Very strange and difficult to troubleshoot!