1
0
Fork 0
peertube/shared/utils/miscs/email-child-process.js
Josh Morel af37210c0b throw error if MailDev doesn't run
also allow calling in multiple file
2018-12-17 10:59:07 +01:00

27 lines
586 B
JavaScript

const MailDev = require('maildev')
// must run maildev as forked ChildProcess
// failed instantiation stops main process with exit code 0
process.on('message', (msg) => {
if (msg.start) {
const maildev = new MailDev({
ip: '127.0.0.1',
smtp: 1025,
disableWeb: true,
silent: true
})
maildev.on('new', email => {
process.send({ email })
})
maildev.listen(err => {
if (err) {
// cannot send as Error object
return process.send({ err: err.message })
}
return process.send({ err: null })
})
}
})