我已经设置了这样的电子邮件:
nodemailer = require("nodemailer");
...
nodemailer.SMTP = {
host: 'smtp.gmail.com', // required
port: 465, // optional, defaults to 25 or 465
domain: 'smtp.gmail.com', // domain used by client to identify itself to server
authentication: 'login', // optional, false by default
user: '1*******@gmail.com', // used only when use_authentication is true
pass: '*******' // used only when use_authentication is true
}
// send an e-mail
nodemailer.send_mail(
// e-mail options
{
sender: '1*******@gmail.com',
to:'2*******@gmail.com',
subject:'Hello!',
html: '<p><b>Hi,</b> how are you doing?</p>',
body:'Hi, how are you doing?'
},
// callback function
function(error, success){
console.log('Message ' + success ? 'sent' : 'failed');
}
回拨功能日志&#34;已发送&#34;但电子邮件永远不会发送。我按照本教程http://www.thihaz.com/?p=218
进行了操作我还需要另外设置smth吗?
答案 0 :(得分:2)
您可以nodemailer
照顾相应的服务器,例如Gmail:
var smtpTransport = nodemailer.createTransport("SMTP",{
auth: {
user: "gmail.user@gmail.com", // service is detected from the username
pass: "userpass"
}
});
然后执行:
transport.sendMail()
这应该让你走上正确的道路。