The code is as simple as possible :
[{"id":"b0fe7e8b.25abf","type":"e-mail","z":"1c590d17.efd25b","server":"your.email@email.com","port":"465","secure":true,"tls":true,"name":"","dname":"Email","x":910,"y":500,"wires":[]},{"id":"5bff5262.335c44","type":"inject","z":"1c590d17.efd25b","name":"Go","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":550,"y":500,"wires":[["3ff07fff.990598"]]},{"id":"3ff07fff.990598","type":"function","z":"1c590d17.efd25b","name":"Email","func":"msg.payload = 'Test';\n\nlet data = {file : 'File Content'};\n\n\nmsg.topic = 'Test Message';\nmsg.attachments = [{ filename: 'body.txt',\n content: data }];\n\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":720,"y":500,"wires":[["b0fe7e8b.25abf"]]}]
The problem would be that an object is placed, "by mistake", in the attachment. Correct would be string or an instance of Buffer or Uint8Array.
Now, we have the following situations:
1). Windows 7 Pro & 10 Pro, NodeRed 1.2.7, npm v6.14.10, and NodeJS 12.20.1
If I run the program I get the error in the console:
[error] [e-mail: xxxxxxxx] TypeError [ERR_INVALID_ARG_TYPE]: The "chunk" argument must be of type string or an instance of Buffer. Received an instance of Object.
Everything is normal so far, nothing unusual.
2). Amazon Ubuntu with NodeRed 1.2.7, npm v6.14.10, but with NodeJS v14.15.4. I also use PM2.
If I run the program, NodeRed shuts down (but restarts automatically due to PM2) :
0|node-red | TypeError [ERR_INVALID_ARG_TYPE]: The "chunk" argument must be of type string or an instance of Buffer or Uint8Array. Received an instance of Object
0|node-red | at PassThrough.Writable.write (internal/streams/writable.js:285:13)
0|node-red | at PassThrough.Writable.end (internal/streams/writable.js:567:10)
0|node-red | at Immediate._onImmediate (/home/ubuntu/.node-red/node_modules/nodemailer/lib/mime-node/index.js:961:46)
0|node-red | at processImmediate (internal/timers.js:461:21) {
0|node-red | code: 'ERR_INVALID_ARG_TYPE'
0|node-red | }
0|node-red | 10 Jan 21:12:26 - [red] Uncaught Exception:
0|node-red | 10 Jan 21:12:26 - TypeError [ERR_INVALID_ARG_TYPE]: The "chunk" argument must be of type string or an instance of Buffer or Uint8Array. Received an instance of Object
0|node-red | at PassThrough.Writable.write (internal/streams/writable.js:285:13)
0|node-red | at PassThrough.Writable.end (internal/streams/writable.js:567:10)
0|node-red | at Immediate._onImmediate (/home/ubuntu/.node-red/node_modules/nodemailer/lib/mime-node/index.js:961:46)
0|node-red | at processImmediate (internal/timers.js:461:21)
PM2 | App [node-red:0] exited with code [1] via signal [SIGINT]
PM2 | App [node-red:0] starting in -fork mode-
In addition to the above problem, as a suggestion, would it be possible to send a warning to the editor in the debug window in the event of an error such as "node-red exited with code [1] via signal [SIGINT]"?
I make this suggestion, because using an application like PM2 (which automatically monitors and restarts NodeRed), such a serious error can go unnoticed, and you end up in a situation where you do not know what is happening. Obviously, there are situations where you omit or it is more difficult to follow the console log.
Also, I expose this issue and here : Crash in NodeRed with Email Node · Issue #2814 · node-red/node-red · GitHub