2014-05-17 6 views

답변

0

사용 https://github.com/caolan/async에 대한

`var mailOptions = { 
    from: "xyz <[email protected]>", // sender address 
    to: "[email protected], [email protected], [email protected]", // list of receivers 
    subject: "Hello ", // Subject line 
    text: "Hello world ", // plaintext body 
    html: "<b>Hello world </b>" // html body 
};` 
// send mail with defined transport object 
smtpTransport.sendMail(mailOptions, function(error, response){ 
    if(error){ 
     console.log(error); 
    }else{ 
     console.log("Message sent: " + response.message); 
    } 

    // if you don't want to use this transport object anymore, uncomment following line 
    //smtpTransport.close(); // shut down the connection pool, no more messages 
}); 

:

var async = require("async"); 
// setup e-mail data with unicode symbols 
var mailOptions = { 
    from: "xyz <[email protected]>", // sender address 
    subject: "Hello ✔", // Subject line 
    text: "Hello world ✔", // plaintext body 
    html: "<b>Hello world ✔</b>" // html body 
} 

var toEmail = ["[email protected]", "[email protected]", "[email protected]"]; 
// send mail with defined transport object 
async.forEachLimit(toEmail,1,function(email,callback){ 
    mailOptions["to"] = email; 

    //manipulate the text 
    mailOptions["text"] = "Hi" + email; 

    smtpTransport.sendMail(mailOptions, function(error, response){ 
     if(error){ 
      console.log(error); 
     }else{ 
      console.log("Message sent: " + response.message); 
     } 
     callback(); 
    }); 
}); 

이 당신에게

+0

덕분에 많은 도움이되는지 잘 모릅니다. 도움이 됐어. –