DEV Community

loading...

Sending Mail Using Nodejs, Configure via SMTP Port WebMail

ishwar profile image ishwar chandra tiwari ・1 min read

/*
Nodemailer is a module for Node.js applications to allow easy as cake email sending. The project got started back in 2010 when there was no sane option to send email messages
*/

const nodemailer = require(‘nodemailer’);

/*
SMTP is the main transport in Nodemailer for delivering messages. SMTP is also the protocol used between different email hosts, so its truly universal. Almost every email delivery provider supports SMTP based sending
*/

var smtpTransport = require(‘nodemailer-smtp-transport’);

var transporter = nodemailer.createTransport(smtpTransport ({
tls: {
},
host: ‘’,
secureConnection: false,
port: 587,
auth: {
user: ‘’,
pass: ‘’
}
}));

var mailOptions = {
from: ‘’,
to: ‘’,
subject: ‘This is a test ‘,
text: ‘Hello this testing message’
};

transporter.sendMail(mailOptions, function(error, info){
console.log(“error,info”,error, info);
});

put in tls option rejectUnauthorized: false

/*
rejectUnauthorized: If true, the server certificate is verified against the list of supplied CAs. An error event is emitted if verification fails; err.code contains the OpenSSL error code. Default: true.
*/

Discussion (0)

pic
Editor guide