2018-12-15 08:51:51 -05:00
|
|
|
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',
|
2019-04-24 09:10:37 -04:00
|
|
|
smtp: msg.port,
|
2018-12-15 08:51:51 -05:00
|
|
|
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 })
|
|
|
|
})
|
|
|
|
}
|
|
|
|
})
|