EmailController::resendEmailAction resend an email by loading the recipients from the Email\Log entry and then calling Mail::setDocument() with the original mail document. If that document was created by the form builder, its to/cc/bcc/from/replyTo fields can contain placeholders like %fieldname%, which are only resolved against form submission data at send time and are
never persisted back to the document.
On resend there is no form data available, so setDocument() re-adds these unresolved placeholder strings as recipients on top of (or in place of, for from) the correct addresses already stored in the log, resulting in broken or duplicated recipients.
BC
Always preferring the log's recipients over the document's current fields would be a breaking change: some templates use static, non-placeholder addresses in the document, and an admin may have intentionally edited those fields since the original send, expecting a resend to pick up the change.
Proposed solution
Add a checkbox to the resend and forward confirmation dialog: "Use original recipients."
- Unchecked by default: current behavior, recipients are taken from the mail document.
- If the mail document contains unresolved placeholder fields (e.g.
%fieldname%), the checkbox is automatically checked and set to read-only, with a short help text explaining why, since the document fields cannot be used safely in that case.
- Admins can also check it manually to force using the log's original recipients.
EmailController::resendEmailActionresend an email by loading the recipients from theEmail\Logentry and then callingMail::setDocument()with the original mail document. If that document was created by the form builder, itsto/cc/bcc/from/replyTofields can contain placeholders like%fieldname%, which are only resolved against form submission data at send time and arenever persisted back to the document.
On resend there is no form data available, so
setDocument()re-adds these unresolved placeholder strings as recipients on top of (or in place of, for from) the correct addresses already stored in the log, resulting in broken or duplicated recipients.BC
Always preferring the log's recipients over the document's current fields would be a breaking change: some templates use static, non-placeholder addresses in the document, and an admin may have intentionally edited those fields since the original send, expecting a resend to pick up the change.
Proposed solution
Add a checkbox to the resend and forward confirmation dialog: "Use original recipients."
%fieldname%), the checkbox is automatically checked and set to read-only, with a short help text explaining why, since the document fields cannot be used safely in that case.