const SMTPServer = require("smtp-server").SMTPServervar fs = require("fs")const server = new SMTPServer({ secure: true, key: fs.readFileSync("C:/Users/Jerome/smtp.key"), cert: fs.readFileSync("C:/Users/Jerome/smtp.cer"), size:1024, onAuth(auth, session, callback){ if(auth.username !== 'abc' || auth.password !== 'def'){ return callback(new Error("Invalid Credentials")); } callback(null, {user: 123}); // where 123 is the user id or similar property }, onMailFrom(address, session, callback){ if(address.address !== "nor...@example.com"){ return callback(new Error("Only nor...@example.com is allowed to send emails")) } return callback() }, onData(stream, session, callback){ stream.pipe(process.stdout) stream.on('end', () => { if (stream.sizeExceeded){ return callback(new Error('size excedded')) } return callback(null, "sent") }) }});server.listen(465)server.on('error', function(err){ console.log(err)})const nodemailer = require("nodemailer")const transport = nodemailer.createTransport({ host:"localhost", port:465, secure:true, auth: { type:"login", user:"abc", pass:"def" }, tls: { rejectUnauthorized: false }})transport.sendMail({ from:"nor...@example.com", to:"xx...@gmail.com", subject:"test", text:"test"}, function(err,info){ if (err) { console.log(err) } else { console.log(info.response) }})