1 import MailDev from '@peertube/maildev'
5 private static instance: MockSMTPServer
6 private started = false
8 private emails: object[]
10 collectEmails (port: number, emailsCollection: object[]) {
11 return new Promise<number>((res, rej) => {
12 this.emails = emailsCollection
18 this.maildev = new MailDev({
25 this.maildev.on('new', email => {
26 this.emails.push(email)
28 console.log('pushed email', email)
31 this.maildev.listen(err => {
32 if (err) return rej(err)
42 if (!this.maildev) return
47 MockSMTPServer.instance = null
50 static get Instance () {
51 return this.instance || (this.instance = new this())
55 // ---------------------------------------------------------------------------