我来自PHP的世界,我习惯使用mail()来发送快速诊断电子邮件。 在NodeJS的标准库中是否有一个模块或方法,大致相当于此?
答案 0 :(得分:7)
不确定
group_id | array_agg
106 | {2147,2138,2144}
107 | {2132,2510,2139}
答案 1 :(得分:6)
Nodemailer是一种流行,稳定且灵活的解决方案:
完全使用看起来像这样(最高位只是设置 - 所以你只需要为每个应用程序执行一次):
var nodemailer = require("nodemailer");
// create reusable transport method (opens pool of SMTP connections)
var smtpTransport = nodemailer.createTransport("SMTP",{
service: "Gmail",
auth: {
user: "gmail.user@gmail.com",
pass: "userpass"
}
});
// setup e-mail data with unicode symbols
var mailOptions = {
from: "Fred Foo ✔ <foo@blurdybloop.com>", // sender address
to: "bar@blurdybloop.com, baz@blurdybloop.com", // 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
});