[Fix] Mail #0048326: Send and delete scheduled mails as mailbox owner - #12067
Merged
mjansenDatabay merged 6 commits intoSep 18, 2026
Merged
mjansenDatabay merged 6 commits into
mjansenDatabay merged 6 commits into
Conversation
ScheduledMailsCron used the cron actor for enqueue() and deleteMails(), so outbox rows were never removed (DELETE matched user_id of cron user). Per mail, use the outbox owner's ilFormatMail/ilMail instance, delete only after successful send, and log enqueue validation errors.
mjansenDatabay
requested changes
Sep 15, 2026
Keep cron status OK when individual mails fail, summarize problems in the result message (max 400 chars), cache ilFormatMail/ilMail per owner, remove unnecessary withContextId call, and delete orphan outbox rows without owner.
mjansenDatabay
requested changes
Sep 15, 2026
Move outbox deletion into OutboxRepository, use structured logger placeholders with short cron summaries, cast mail_id/user_id directly, and make MailDeliveryData user_id a non-nullable int defaulting to 0.
mjansenDatabay
requested changes
Sep 15, 2026
Delete sent scheduled mails via the cached ilFormatMail instance and remove orphan outbox rows without a valid user including mail_attachment cleanup.
mjansenDatabay
requested changes
Sep 16, 2026
mjansenDatabay
requested changes
Sep 17, 2026
mjansenDatabay
left a comment
Contributor
There was a problem hiding this comment.
Hi @fhelfer ,
IMO the PR looks good now, except for one thing: We should still try to delete sent mail records which hold an existing owner (with the corresponding $mailer instance).
Best regards,
Michael
mjansenDatabay
approved these changes
Sep 18, 2026
mjansenDatabay
pushed a commit
that referenced
this pull request
Sep 18, 2026
…#12067) Co-authored-by: mjansen <mjansen@databay.de>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes Mantis #48326: scheduled outbox mails were sent again every night and never removed from the outbox.
Root cause:
ScheduledMailsCronused a singleilMail/ilFormatMailinstance bound to the cron actor ($DIC->user()). After sending,deleteMails()executed:Outbox rows belong to the scheduling user, so the DELETE matched 0 rows (no error, cron status OK). The same rows were picked up on every run.
Additionally, send/enqueue ran as the cron user instead of the mailbox owner (wrong sender, wrong attachment file pool, wrong SMTP permission checks).
Changes
mail.user_idinOutboxDatabaseRepositoryand expose it onMailDeliveryDatailFormatMail($owner_id)andilMail($owner_id)enqueue()for that mail (not infinally, not batched with wrong user)enqueue()