Always save to D1 before emailing externally
Network requests to external APIs can experience momentary timeouts. Writing the verified inquiry row to D1 first guarantees your customer request is safely recorded before email delivery runs.
Escape every user-submitted field inside HTML email bodies
Sanitize &, <, >, quotes, and strip header newlines from subjects or reply-to strings before passing HTML templates to Resend so spam payloads never corrupt layouts.
const escapeHtml = (s) => String(s) .replace(/&/g, '&') .replace(/</g, '<') .replace(/>/g, '>') .replace(/"/g, '"');
Do not silently fail if an optional email worker isn't bound yet
Log non-fatal delivery metadata cleanly and design clear error feedback whenever neither D1 nor email forwarding succeeds so visitors never think a dropped submission went through.
Common questions
Should every confirmation email copy the full form message back to the sender?
Be conservative—for public forms, sending a concise confirmation ('Received reference #1234') avoids spammers abusing your site as a third-party message relay.
Can Resend track whether an inquiry alert bounced?
Yes. Resend exposes delivery webhooks and bounce logs cleanly on verified sending domains.
References
Provider interfaces and limits can change. Consult the original documentation before changing production settings.