Clone and edit this document
Runkit
Runkit
home page
user forum
new notebook
clone notebook
download notebook
support & documentation
log in
sign up
new notebook
help & feedback
clone this notebook
download this notebook
Sign In
Sign Up
RunKit + npm:
node v10.24.1
version:
1.0.0
endpoint
share
tweet
const { SMTPServer } = require('smtp-server'); const nodemailer = require('nodemailer'); const SMTPServerInstance = new SMTPServer({ // logger: true, // debug: true, authOptional: true }); SMTPServerInstance.listen(() => { console.log('SMTP server is listening!\n'); const transporter = nodemailer.createTransport({ // logger: true, // debug: true, host: SMTPServerInstance.server.address().address, port: SMTPServerInstance.server.address().port, ignoreTLS: true }); console.log('Sending email...'); transporter .sendMail({ from: 'sender@example.com', to: 'receiver@example.com', subject: 'Subject', text: 'Text', html: 'HTML' }) .then((info) => { console.log('Email successfully sent!', info); }) .catch((err) => { console.log('Error when sending an email:', err); }) .finally(() => { SMTPServerInstance.close(); }); });
Created from: https://npm.runkit.com/
Loading…
no comments
sign in
to comment