observe-to-email

git clone git://git.codymlewis.com/observe-to-email.git
Log | Files | Refs | README

commit 9508e0b44975e4a2307558bb9ee0819df86f9c75
parent 55b2dde3f6d08f08354680226e85368482a781da
Author: Cody Lewis <luxdotsugi@gmail.com>
Date:   Tue, 11 Sep 2018 09:57:55 +1000

Added some fail reduction measures to the emailing system

Diffstat:
Mroutes/index.js | 8++++++--
1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/routes/index.js b/routes/index.js @@ -22,11 +22,11 @@ router.get('/observe/submit', function(req, res, next) { '\\\\\\hline\nOther observations & ' + req.query.otherComment + '\\\\\n\\hline\n\\end{tabular}\n\\end{center}'; var subject = 'HLA9000 - Observations: ' + today.toDateString(); - email(subject, msg); + email(subject, msg, 0); res.redirect('/success'); }); -function email(subject, msg) { +function email(subject, msg, i) { var transporter = nodemailer.createTransport({ service: 'gmail', auth: { @@ -43,6 +43,10 @@ function email(subject, msg) { transporter.sendMail(mailOptions, function(error, info){ if (error) { console.log(error); + if(i < 5) { + console.log("Trying again"); + email(subject, msg, i + 1); + } } else { console.log('Email sent: ' + info.response); }