mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2025-10-16 12:05:41 +00:00
25 lines
642 B
TypeScript
25 lines
642 B
TypeScript
import sendmail = require("sendmail");
|
|
|
|
const emailSender = sendmail({
|
|
silent: false
|
|
});
|
|
|
|
const sendEmail = (options: sendmail.MailInput): Promise<boolean> =>
|
|
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 <noreply@mydomain.com>",
|
|
to: "test@mydomain.com",
|
|
subject: "First Test",
|
|
html: "This is a Test message!"
|
|
});
|