Issue
When an Email Marketing record is scheduled for a future date, the emails are queued before the scheduled run date. If the “Send Campaign Emails” scheduler runs after queueing but before the run date, it finds no due entries and sets the record to “Sent”. The queued emails are never sent: they stay in the queue with 0 send attempts, and since the record is “Sent”, the send job never picks them up again.
This affects practically every mailing that is planned in advance, as there is almost always a send run between queueing and the run date.
The failure is completely silent:
- No error in any log file (
prod.log,suitecrm.log) - Email Marketing Diagnostics shows everything OK
- The status “Sent” suggests the mailing went out, while no recipient received it. The “Sent/Attempted” chart stays at 0.
Test emails are not affected, as they bypass the queue.
This is a regression: in SuiteCRM 7.x, mailings scheduled in advance were sent correctly.
Possible Fix
The record is set to “Sent” in
core/modules/Campaigns/Service/Email/Queue/DefaultEmailQueueProcessor.php:
if (empty($nextQueueEntries) && $isQueueingFinished) {
$this->setSent($emRecord);
}
getEntriesToSend() in DefaultEmailQueueManager.php only returns entries whose send date has been reached ($now). Entries that are queued but not yet due are therefore treated as “nothing left to send”.
Possible fixes:
- Only call
setSent()if there are no remaining queue entries for the record at all (not just no due entries), or - Do not process the record in the send job before its scheduled run date, or
- Do not queue emails before the scheduled run date.
Related: Campaigns get marked incorrectly as Sent · Issue #868 · SuiteCRM/SuiteCRM-Core · GitHub
(same code path, triggered there by failed sends / wrong SMTP credentials)
Steps to Reproduce the Issue
1. Make sure the schedulers "Queue Campaign Emails" and "Send Campaign Emails" run every 15 minutes (e.g. at :00, :15, :30, :45)
2. Create a campaign with a target list and an Email Marketing record
3. At 11:29, schedule the record with run date 11:50
4. At 11:30, the queue job queues the emails (before the run date)
5. At 11:45, the send job finds no due entries and sets the record to "Sent" (before the run date!)
6. After 11:50, the emails remain in the queue with 0 send attempts and are never sent
Counter-test with the same target list:
1. At 11:50, schedule a record with run date 11:55
2. At 12:00, the emails are queued and sent correctly (run date already passed when queueing)
Context
We migrated from SuiteCRM 7.x to 8.10.2. Since then, our planned newsletters were silently not sent, while the records showed “Sent”. The only reliable workaround is to schedule mailings with a run date of “now” or slightly in the past, so that emails are due when they are queued. Planning newsletters in advance is currently not possible.
Version
8.10.2