nodejs发送邮件

来源:互联网 发布:淘宝换绑支付宝 编辑:程序博客网 时间:2024/05/13 10:51





var nodemailer = require('nodemailer');


// one time action to set up SMTP information
nodemailer.SMTP = {
    host: 'smtp.example.com'
}


// send an e-mail
nodemailer.send_mail(
    // e-mail options
    {
        sender: 'me@example.com',
        to:'you@example.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');
    }
);


简单吧,详细的库安装和更详细的使用方法见

https://github.com/andris9/Nodemailer

原创粉丝点击