Browse Source

Added some doc

Brendan Abolivier 8 years ago
parent
commit
25bd4cd295
Signed by: Brendan Abolivier <contact@brendanabolivier.com> GPG key ID: 8EF1500759F70623
1 changed files with 4 additions and 1 deletions
  1. 4
    1
      server.js

+ 4
- 1
server.js View File

74
 // done(): Called once each mail has been sent
74
 // done(): Called once each mail has been sent
75
 function sendMails(params, update, done) {
75
 function sendMails(params, update, done) {
76
     let mails = settings.recipients.map((recipient) => {
76
     let mails = settings.recipients.map((recipient) => {
77
+        // Promise for each recipient to send each mail asynchronously
77
         return new Promise((sent) => {            
78
         return new Promise((sent) => {            
78
             params.to = recipient;
79
             params.to = recipient;
79
-            
80
+            // Send the email
80
             transporter.sendMail(params, (err, infos) => {
81
             transporter.sendMail(params, (err, infos) => {
82
+                // Promise callback
81
                 sent();
83
                 sent();
82
                 if(err) {
84
                 if(err) {
83
                     return next(err, recipient);
85
                     return next(err, recipient);
86
             });
88
             });
87
         });
89
         });
88
     });
90
     });
91
+    // Run all the promises (= send all the mails)
89
     Promise.all(mails).then(done);
92
     Promise.all(mails).then(done);
90
 }
93
 }
91
 
94