nodemailer-mailgun-transport icon indicating copy to clipboard operation
nodemailer-mailgun-transport copied to clipboard

source.on is not a function with cid attachments

Open mschoeffmann opened this issue 3 years ago • 4 comments

after upgrading from 2.0.3 to 2.1.3, sending an email throws the following exception:

error: TypeError: source.on is not a function
    at Function.DelayedStream.create (/Users/x/Source/x/app-backend/node_modules/delayed-stream/lib/delayed_stream.js:33:10)
    at FormData.CombinedStream.append (/Users/x/Source/x/app-backend/node_modules/combined-stream/lib/combined_stream.js:45:37)
    at FormData.append (/Users/x/Source/x/app-backend/node_modules/form-data/lib/form_data.js:75:3)
    at /Users/x/Source/x/app-backend/node_modules/mailgun.js/dist/mailgun.js:2:13253
    at Array.forEach (<anonymous>)
    at /Users/x/Source/x/app-backend/node_modules/mailgun.js/dist/mailgun.js:2:13230
    at Array.forEach (<anonymous>)
    at e.postMulti (/Users/x/Source/x/app-backend/node_modules/mailgun.js/dist/mailgun.js:2:13164)
    at e.create (/Users/x/Source/x/app-backend/node_modules/mailgun.js/dist/mailgun.js:2:8661)
    at mailgunSend (/Users/x/Source/x/app-backend/node_modules/nodemailer-mailgun-transport/src/index.js:149:40)
    at Object.send (/Users/x/Source/x/app-backend/node_modules/nodemailer-mailgun-transport/src/index.js:127:26)

this is the base for newly created emails:

const email = new Email({
  transport,
  message: {
    from: config.email.from,
    attachments: [
      {
        filename: 'logo.png',
        path: `${path.resolve('emails')}/logo.png`,
        cid: '[email protected]',
      },
    ],
  },
  juiceResources: {
    preserveImportant: true,
    webResources: {
      relativeTo: path.resolve('emails'),
    },
  },
  send: true, // send also in development mode
  preview: config.env === 'development' && {
    open: {
      app: 'google chrome',
      wait: false,
    },
  },
});

and the problem goes away after removing the line cid: '[email protected]'

after some reseach, i guess this is related to https://github.com/mailgun/mailgun-js/pull/141 but since the update from 2.0.3 to 2.1.3 broke it, i wanted to keep you informed ...

mschoeffmann avatar May 14 '21 21:05 mschoeffmann

I don't even know if mailgun.js really fixed the inline image support. They doc is still bad, and the mailgun/mailgun-js#141 just adds a few things, without any additional doc or test.

TheArKaID avatar May 19 '21 05:05 TheArKaID

Thank you @mschoeffmann

orliesaurus avatar May 19 '21 15:05 orliesaurus

i'm seeing this error too

big thanks to @mschoeffmann for letting us know which version to downgrade to in the meantime!

freysie avatar May 28 '21 20:05 freysie

Thank you for this issue, saved me some time digging into what is happening :)

bartoszhernas avatar Jun 07 '21 14:06 bartoszhernas