Skip to content

fix(email): ensure unique log ID for each recipient - #137

Merged
JoelAlphonso merged 1 commit into
mainfrom
fix/email-log-duplicate-recipients
Nov 19, 2026
Merged

JoelAlphonso merged 1 commit into
mainfrom
fix/email-log-duplicate-recipients

Conversation

@JoelAlphonso

Copy link
Copy Markdown
Contributor

Summary

Email::logSend() creates one email log per recipient but assigns every log the same primary key ($logId). Sending an email to more than one To, CC, or BCC recipient therefore fails on the second insert:

SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry ... for key PRIMARY

This change keeps the original message ID for the first recipient (so open/link tracking continues to work) and appends the recipient index to subsequent log IDs.

Changes

  • Generate a unique log ID for each additional recipient.
  • Add a regression test covering an email sent to three recipients.

Testing

phpunit packages/email/tests/Charcoal/Email/EmailLogSendTest.php

@JoelAlphonso
JoelAlphonso merged commit 8721374 into main Nov 19, 2026
37 checks passed
@charcoal-butler

Copy link
Copy Markdown
Contributor

🎉 This PR is included in version 5.3.12 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant