orliesaurus / nodemailer-mailgun-transport

nodemailer is an amazing node module to send emails within any of your nodejs apps. This is the transport plugin that goes with nodemailer to send email using Mailgun 🔫
MIT License
880 stars 97 forks source link

source.on is not a function with cid attachments #107

Open mschoeffmann opened 3 years ago

mschoeffmann commented 3 years ago

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: 'logo@mymail.domain',
      },
    ],
  },
  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: 'logo@mymail.domain'

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 ...

TheArKaID commented 3 years ago

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.

orliesaurus commented 3 years ago

Thank you @mschoeffmann

freysie commented 3 years ago

i'm seeing this error too

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

bartoszhernas commented 3 years ago

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