Nodemailer is used to write a project to monitor some problems encountered.

  node.js, question
var http = require('http');
 var nodemailer=require('nodemailer');
 var checkfile="http://127.0.0.1:8081/assets/css/main.css";  //Request the static file of the project to judge whether the project is hung up or not
 var erroroption={
 from:'server<xxxxx@qq.com>',
 to:'xxxxx@qq.com',
 cc:'xxxxx@qq.com,xxxxxx@qq.com',
 Subject: "Engineering Error",
 Text: "The server is dead, please handle it as soon as possible."
 };
 var restartoption={
 from:'server<xxxxx@qq.com>',
 to:'xxxxx@qq.com',
 cc:'xxxxx@qq.com,xxxxxx@qq.com',
 Subject: "Project Recovery",
 Text: "The server has been restored."
 };
 var mail=nodemailer.createTransport({
 host: "smtp.qq.com",
 server:'QQ',
 port:465,
 secureConnection:true,
 auth:{
 user:'xxxxxxx@qq.com',
 pass:'xxxxxxxx'
 bracket
 });
 var restart=true;  //Judge whether the program has been started
 var timer = setInterval(function () {
 http.get(checkfile, function (res) {
 if(!  restart){
 mail.sendMail(restartoption, function (error, info) {
 var date=new Date();
 Log (date plus' project resumed');
 restart = true;
 });
 bracket
 }).on('error', function (e) {
 if(restart) {
 mail.sendMail(erroroption, function (error, info) {
 var date=new Date();
 (date plus' project is dead');
 restart = false;
 });
 bracket
 });
 }, 60*1000);  //Detection frequency is 60S once

Recently, nodemailer was used to write a function of monitoring engineering. The main thing is to send an e-mail reminder when the project hangs up, and then send an e-mail notification when the project restarts. However, I have encountered some problems. I set here to send only one email every time I hang up or restart, but sometimes I send several emails in a row, Why is this?. There are also times when callback is executed, but the mail is not received.

Sending emails is very slow, and the server response is still required after execution, which is normal.