import sendmail = require("sendmail"); const emailSender = sendmail({ silent: false }); const sendEmail = (options: sendmail.MailInput): Promise => new Promise((resolve, reject) => { emailSender(options, (err, reply) => { // if error happened or returned code is now started with 2** if (err || !reply.startsWith("2")) { reject(err); } else { resolve(true); } }); }); sendEmail({ from: "Test Mail ", to: "test@mydomain.com", subject: "First Test", html: "This is a Test message!" });