var nodemailer = require('nodemailer');
// create SMTP transport
var transporter = nodemailer.createTransport({
service: 'Gmail',
auth: {
user: '[email protected]',
pass: '******'
}
});
// transporter object for all e-mails
var mail = {
from: 'XXX XXXX <[email protected]>', // sender address
to: '[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
transporter.sendMail(mail, function (error, info) {
if (error) {
return console.log('Error : ' + error);
}
console.log('Mail sent: ' + info.response);
});
發送電子郵件遠不在節點的「開箱即用」功能之外,但可能有一個庫。檢查NPM。另外,將它委託給消息傳遞代理可能會更好,而不是讓節點完成所有工作。 – UpTheCreek 2013-04-07 17:52:10
[nodemailer](https://github.com/andris9/Nodemailer)是一個非常複雜的庫,[node-email](https://github.com/aheckmann/node-email)更簡單但仍然有用。兩者都可以委託給MTA,這確實是你想要的。 – robertklep 2013-04-07 17:54:56