Bug Report
The mapAttachments function in @payloadcms/email-resend has two bugs that make all email attachments arrive corrupt or fail entirely.
Bug 1: path is not supported
The docs recommend using path for cloud storage:
attachments: [{ filename: 'invoice.pdf', path: mediaDoc.url }]
But mapAttachments requires content to exist and throws if it's missing:
if (!attachment.filename || !attachment.content) {
throw new APIError('Attachment is missing filename or content', 400);
}
The path property is defined in the Attachment type but never read or forwarded.
Bug 2: content as base64 string produces corrupt files
The docs also show passing base64 content:
attachments: [{ filename: 'invoice.pdf', content: fileBuffer.toString('base64') }]
But mapAttachments wraps the string in Buffer.from(attachment.content) (treating base64 as UTF-8 text). This Buffer is then serialized via JSON.stringify(), producing {"type":"Buffer","data":[83,71,...]} instead of the base64 string that the Resend REST API expects. The attachment arrives corrupt.
Suggested fix
mapAttachments should:
- Pass
path through when content is absent
- Keep base64 strings as-is (don't wrap in Buffer) since
JSON.stringify is used downstream
Reproduction
Any call to payload.sendEmail() with attachments using the Resend adapter.
Version: @payloadcms/email-resend@3.73.0 (also present on main branch as of March 2026)
Bug Report
The
mapAttachmentsfunction in@payloadcms/email-resendhas two bugs that make all email attachments arrive corrupt or fail entirely.Bug 1:
pathis not supportedThe docs recommend using
pathfor cloud storage:But
mapAttachmentsrequirescontentto exist and throws if it's missing:The
pathproperty is defined in theAttachmenttype but never read or forwarded.Bug 2:
contentas base64 string produces corrupt filesThe docs also show passing base64 content:
But
mapAttachmentswraps the string inBuffer.from(attachment.content)(treating base64 as UTF-8 text). This Buffer is then serialized viaJSON.stringify(), producing{"type":"Buffer","data":[83,71,...]}instead of the base64 string that the Resend REST API expects. The attachment arrives corrupt.Suggested fix
mapAttachmentsshould:paththrough whencontentis absentJSON.stringifyis used downstreamReproduction
Any call to
payload.sendEmail()with attachments using the Resend adapter.Version:
@payloadcms/email-resend@3.73.0(also present onmainbranch as of March 2026)