Fixed SendGrid support.

Ylian Saint-Hilaire committed Jan 24, 2021 at 22:15 UTC aa01c671a9c2246005de32d6c446e3d4959a0994
1 file changed +17
meshmail.js
+17
@@ -342,9 +342,26 @@ module.exports.CreateMeshMail = function (parent) {
342 obj.sendGridServer
343 .send(mailToSend)
344 .then(function () {
345 + obj.sendingMail = false;
346 parent.debug('email', 'SendGrid sending success.');
347 + obj.pendingMails.shift();
348 + obj.retry = 0;
349 + sendNextMail();
350 }, function (error) {
351 + obj.sendingMail = false;
352 parent.debug('email', 'SendGrid sending error: ' + JSON.stringify(error));
353 + obj.retry++;
354 + // Wait and try again
355 + if (obj.retry < 3) {
356 + setTimeout(sendNextMail, 10000);
357 + } else {
358 + // Failed, send the next mail
359 + parent.debug('email', 'SendGrid server failed (Skipping): ' + JSON.stringify(err));
360 + console.log('SendGrid server failed (Skipping): ' + JSON.stringify(err));
361 + obj.pendingMails.shift();
362 + obj.retry = 0;
363 + sendNextMail();
364 + }
365 });
366 } else if (obj.smtpServer != null) {
367 // SMTP send