mail icon indicating copy to clipboard operation
mail copied to clipboard

Cannot send attachment using Resend

Open magnus-trent opened this issue 1 year ago • 1 comments
trafficstars

Package version

6.12.1

Describe the bug

When sending an email using a class email, everything works until trying to follow the attaching files process. All I get is failures, and upon looking at the error I get "Unable to send email using the resend transport: Response code 422 (Unprocessable Entity)".

export default class ChangelogNotification extends BaseMail {
  subject = 'Tailwind test'

  /**
   * The "prepare" method is called automatically when
   * the email is sent or queued.
   */
  prepare() {
    this.message.to('********@*****.net')
    this.message.html(ChangelogEmail({ text: 'Trust reputation' }))
    this.message.attach(app.makePath('public/deepslate.png'), {})
  }
}

Reproduction repo

No response

magnus-trent avatar Jul 24 '24 00:07 magnus-trent

Same thing happened to me with attach.

embedData fixed the 422 issue and I was able to send my attachment.

const myAttachmentPath = app.publicPath("attachment.png");
const fileBuffer= await fs.readFile(myAttachmentPath );

this.message
 .to(this.props.email)
 .html(html)
 .text(text)
 .embedData(fileBuffer, 'fileName', {
    // encoding: "base64",
    // contentType
    // fileName
 })

CodingDive avatar Nov 25 '24 00:11 CodingDive

For those who stumble upon this issue, trying to make a cid attachment, it does not seem to be supported in resend in this moment https://github.com/resend/resend-node/issues/319

CodingDive avatar Nov 25 '24 00:11 CodingDive

@CodingDive Thanks for narrowing down the issue. So we just have to wait for Resend to allow this?

thetutlage avatar Nov 25 '24 06:11 thetutlage

@CodingDive Thank you for the embedData tip!

magnus-trent avatar Nov 25 '24 19:11 magnus-trent

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

stale[bot] avatar Apr 26 '25 01:04 stale[bot]

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

stale[bot] avatar Jun 27 '25 00:06 stale[bot]

Closing as the limitation is on the Resend side

thetutlage avatar Jun 27 '25 09:06 thetutlage