Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Long URLs in List-Unsubscribe cause failure only when List-Unsubscribe is added during sendEmail step #1694

Open
voran opened this issue Nov 11, 2024 · 4 comments

Comments

@voran
Copy link

voran commented Nov 11, 2024

During our testing, we found that if the list-unsubscribe URL is long and gets folded, DKIM verification fails.

This was already reported in #1654 but we have additional findings to report which we believe will narrow down the root cause.

We found that if we add a long list-unsubscribe header during the sendEmail step, DKIM will fail, however it will succeed if:

  1. list-unsubscribe header is added during the createTransport step
    ...or...
  2. list-unsubscribe header is passed as prepared: true as suggested in Too long URLs in the List-Unsubscribe header causes the DKIM signature verification to fail #1654

Code snippet and resulting email tested in mail-tester which causes DKIM failure

    const transporter = nodemailer.createTransport({
      host: 'postfix',
      port: 25,
      secure: false,
      dkim: {
        domainName: ... // Client's domain
        keySelector:  '...', // Selector used for the DKIM key
        privateKey: .., // Client-specific DKIM private key
      },
    });

    transporter.sendEmail(
          from: '...',
          to: toEmail ,
          ...
          envelope: {
            from: '...',
            to: toEmail,
          },
          headers: {
            'List-Unsubscribe-Post': 'List-Unsubscribe=One-Click',
            'List-Unsubscribe': `<long-url>`,
          }
       );

Code snippet and resulting email tested in mail-tester where DKIM is valid

    const transporter = nodemailer.createTransport({
      host: 'postfix',
      port: 25,
      secure: false,
      dkim: {
        domainName: ... // Client's domain
        keySelector:  '...', // Selector used for the DKIM key
        privateKey: .., // Client-specific DKIM private key
      },
      headers: {
        'List-Unsubscribe-Post': 'List-Unsubscribe=One-Click',
        // https://github.com/nodemailer/nodemailer/issues/1654
        'List-Unsubscribe': `<long-url>`,
      },
    });

    transporter.sendEmail(
          from: '...',
          to: toEmail ,
          ...
          envelope: {
            from: '...',
            to: toEmail,
          },
          headers: {
            'List-Unsubscribe-Post': 'List-Unsubscribe=One-Click',
            'List-Unsubscribe': `<long-url>`,
          }
       );

We have also tried moving both headers and the dkim attributes to the sendEmail step but this also causes the DKIM to fail.

The fact that the behavior is different depending on where the headers are added indicates that this might be a bug in nodemailer.
We would much prefer to keep the list-unsubscribe in the sendEmail step so that we can reuse the transport while sending to multiple users with different list-unsubscribe URLs.

Copy link
Contributor

This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 5 days.

@dargmuesli
Copy link

I think this is still relevant 👀

Copy link
Contributor

This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 5 days.

@dargmuesli
Copy link

Again, this is still relevant, could someone turn off the inactivity bot for this please? I can confirm this being an active issue.
cc @andris9

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants