node-imap
node-imap copied to clipboard
Cannot get the first example to run?
I got this error
Error [ERR_STREAM_DESTROYED]: Cannot call write after a stream was destroyed
at doWrite (_stream_writable.js:399:19)
at clearBuffer (_stream_writable.js:542:7)
at Socket.Writable.uncork (_stream_writable.js:338:7)
at JSStreamSocket.doWrite (internal/js_stream_socket.js:171:17)
at JSStream.onwrite (internal/js_stream_socket.js:28:57)
at Socket.ondata (internal/js_stream_socket.js:72:22)
at Socket.emit (events.js:315:20)
at addChunk (_stream_readable.js:295:12)
at readableAddChunk (_stream_readable.js:271:9)
at Socket.Readable.push (_stream_readable.js:212:10) {
code: 'ERR_STREAM_DESTROYED',
source: 'socket'
}
events.js:292
throw er; // Unhandled 'error' event
^
Error: self signed certificate
at TLSSocket.onConnectSecure (_tls_wrap.js:1501:34)
at TLSSocket.emit (events.js:315:20)
at TLSSocket._finishInit (_tls_wrap.js:936:8)
at TLSWrap.ssl.onhandshakedone (_tls_wrap.js:710:12)
at Socket.ondata (internal/js_stream_socket.js:72:22)
at Socket.emit (events.js:315:20)
at addChunk (_stream_readable.js:295:12)
at readableAddChunk (_stream_readable.js:271:9)
at Socket.Readable.push (_stream_readable.js:212:10)
at TCP.onStreamRead (internal/stream_base_commons.js:186:23)
Emitted 'error' event on Connection instance at:
at TLSSocket._onError (C:\Users\TechWreck\node_modules\imap\lib\Connection.js:151:10)
at TLSSocket.emit (events.js:315:20)
at emitErrorNT (internal/streams/destroy.js:92:8)
at emitErrorAndCloseNT (internal/streams/destroy.js:60:3)
at processTicksAndRejections (internal/process/task_queues.js:84:21) {
code: 'DEPTH_ZERO_SELF_SIGNED_CERT',
source: 'socket'
}
The server you're connecting to is presenting a self-signed certificate. If this is expected (and not something/someone trying to MITM your connection), then you need to pass the CA or certificate of the server in via the tlsOptions object in order for the connection to be trusted.
https://github.com/mscdex/node-imap/issues/724 shows the exact change needed in case you use gmail like in the example. (helped me solving the same problem)