码迷,mamicode.com
首页 > 其他好文 > 详细

node(邮件发送特性)

时间:2015-02-12 12:12:00      阅读:114      评论:0      收藏:0      [点我收藏+]

标签:

1、安装 npm install nodemailer

https://github.com/andris9/Nodemailer

2、配置发邮件的账户开启SMTP功能;

3、程序样例如下:

var nodemailer = require(‘nodemailer‘);

var user = ‘fredric@XXXX.com‘,
    password = ‘XXXX‘;

// create reusable transporter object using SMTP transport
var transporter = nodemailer.createTransport({
    service: ‘QQ‘,
    auth: {
        user: user,
        pass: password
    }
});

// setup e-mail data with unicode symbols
var mailOptions = {
    from: ‘Fredric<‘ + user + ‘>‘, // sender address
    to: ‘Fredric@qq.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
transporter.sendMail(mailOptions, function(error, info){
    if(error){
        console.log(error);
    }else{
        console.log(‘Message sent: ‘ + info.response);
    }
});

 

node(邮件发送特性)

标签:

原文地址:http://www.cnblogs.com/Fredric-2013/p/4287655.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!