Skip to content

List headers getting stripped in Resend Transport #129

@BuyMyBeard

Description

@BuyMyBeard

Package version

10.2.0

Describe the bug

I've been puzzled yesterday because I couldn't find any trace of my List-Unsubscribe headers in the email I received in Gmail.
Looking at the code for the resend transport, it doesn't look like it sets the headers object on the payload, which could explain why I couldn't find any trace of my headers in the received email.

Resend docs: https://resend.com/docs/api-reference/emails/send-email#param-headers
Mail code in question:

#preparePayload(mail: MailMessage) {

my code:

 // In mail class prepare() body
 const postUnsubscribeUrl = signedUrlFor(
      'newsletter.unsubscribe',
      { lang: locale },
      { expiresIn: '90 days', qs: { delivery: delivery.publicId }, prefixUrl: HOST }
    )

    this.message
      .to(contact.email)
      .htmlView(this.getViewPath('html'), payload)
      .textView(this.getViewPath('text'), payload)
      .listUnsubscribe(postUnsubscribeUrl)
      .addListHeader('unsubscribe-post', 'List-Unsubscribe=One-Click')

// Code for sending the mail class instance
const letter = await makeMail(delivery)

    const config = makeResendConfig({
      category: 'marketing_campaign',
      contactId: delivery.contactId,
      campaignId: delivery.campaignId,
      deliveryId: delivery.id,
    })

    try {
      await providerLimiter.resend.schedule(async () => {
        await mail.send(letter, config)
      })

      await markDeliveryAccepted(deliveryId)
    } catch (error: unknown) {
      await markDeliveryAppFailed(deliveryId, error)
      throw error
    }

Reproduction repo

No response

Metadata

Metadata

Assignees

Labels

Type: BugThe issue has indentified a bug

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions