Nodejs uses mailer to send emails
In practical applications, sometimes you need to push messages to you in a timely manner when the server has special information, so that you are prepared and processed. There are a large number of servers in the project, therefore, it is not convenient to Manage Server clusters. When an exception exits on each server, I send an email to my mailbox and restart the Nodejs server.
Not much nonsense, on the instance:
First, install a mail sending module:
npm install mailer
Then introduce the module in the Code:
var email = require(mailer);
Finally, use the module to send an email:
Email. send ({ssl: true, host: smtp.exmail.qq.com, // send smtp.qq.com, receive pop.qq.com domain: [xxx. xxx. xxx. xxx], // you can enter a http://ip.qq.com in your browser/get to: xxx@qq.com, from: xxx@xxx.com, subject: myemail test email, // reply_to: xxx@xxx.com, body: Hello! This is a test of the myemail ., authentication: login, username: xxx@xxx.com, password: xxx, debug: false}, function (err, result) {if (err) {console. log (the err: + err); response. write (JSON. stringify ({prompt message: failed to send, cause of failure: Data Exception}); response. end ();} else {if (result) {console. log (sent successfully); response. write (JSON. stringify ({prompt message: sent successfully}); response. end ();} else {response. write (JSON. stringify ({prompt message: failed to send, cause of failure: Data Exception}); response. end ();}}});
The node. js module is easy to use and may be helpful to you.