chirag04 / mail-listener2

Mail listener library for node.js. Get notification when new email arrived.
MIT License
245 stars 116 forks source link

Unable to get attachments #85

Open dzg opened 2 years ago

dzg commented 2 years ago

This is a fantastic package ... but I can't get downloads. I tried adding attachmentOptions: { stream: "true"} Also tried adding

mailListener.on('data', data => {
    console.log(data)
    if (data.type === 'attachment') {
         console.log(data.filename);
         data.content.pipe(process.stdout);
         data.content.on('end', () => data.release());
    }
});

(based on Mail Parser docs)

mailListener.on("attachment", function(attachment){
  console.log(attachment.path);
});

doesn't return anything... there is no attachment.path ... but there is attachment.stream:

{
  contentType: 'image/png',
  contentDisposition: 'attachment',
  transferEncoding: 'base64',
  generatedFileName: 'attachment.png',
  contentId: '4b07159b34f1287079d4bdf7e77bc295@mailparser',
  stream: Base64Stream {
    _events: [Object: null prototype] {},
    _eventsCount: 0,
    _maxListeners: undefined,
    writable: true,
    checksum: Hash {
      _options: undefined,
      [Symbol(kHandle)]: Hash {},
      [Symbol(kState)]: [Object]
    },
    length: 5245,
    current: '',
    [Symbol(kCapture)]: false
  },
  checksum: '8d8c71ac84d23f92e171922eb89e1271',
  length: 5245
}

What am I missing?