Nodejs process crashes sending mail

Source: Internet
Author: User

After the project was released, the NODEJS process encountered an unpredictable bug, and after the crash, we wanted to notify the developer by mail. It's convenient for us to find problems.

Just have a plug-in, easy to use, recorded here. The plugin name is Nodemailer. Address https://github.com/andris9/Nodemailer/.

Record the use of their own problems encountered in the process, I often use the QQ mailbox, but the example of the test Gmail, then this nodemailer also support what services.

There is an introduction in Nodemailer-wellknown. Here is my implementation code

//for exceptions, the administrator who sent the message to a specific QQ mailbox has found a problemvarServerconfig = require ('.. /shared/config/serverconfig ');varNodemailer = require (' Nodemailer '));functionErrormail (content) {varTransporter =Nodemailer.createtransport ({service:"QQ", auth: {user:ServerConfig.MailUser, Pass:ServerConfig.MailPass}}); varCurdate =NewDate (); varSubject = "Mainserver Crash" +curdate; varhtml = ' <b> ' + content + ' </b> '; varMailoptions ={from:ServerConfig.MailUser, To:ServerConfig.MailUser, Subject:subject, text:' Mail test content ', html:html}; Transporter.sendmail (Mailoptions,function(error,info) {if(Error) Console.log (error); ElseConsole.log (' Message Sent: ' +info.response); });} Module.exports.ErrorMail= Errormail;
View Code

Where Serverconfig is configured to send mailboxes.

var Serverconfig = {        ' [email protected] ',        ' XXXX '}

Nodejs process crashes sending mail

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.