码迷,mamicode.com
首页 > Web开发 > 详细

Nodejs 发送邮件

时间:2017-11-06 11:08:55      阅读:145      评论:0      收藏:0      [点我收藏+]

标签:sharp   ret   .com   time   option   child   func   title   log   

var nodemailer = require("nodemailer");
var mailTitle=‘http://handsupowo.pl/:Releases HandsUp Info‘;
var child_process = require(‘child_process‘);
var fs= require(‘fs‘);

child_process.execFile(‘phantomjs‘,[‘HandsupInfo.js‘],function (err, result) {
console.log("download over");
});

setTimeout(function() {
readFile();


 
 }, 20000);
 
function readFile()
{

   console.log(‘--------ReadFile--------‘);

    fs.readFile(‘DownLoadUrl.txt‘,‘utf-8‘,function(err,data){
        if(err){
         
        }else{
           sendSSLMail(data);
        }
    })

}

function sendSSLMail(mailContent){
var stransporter = nodemailer.createTransport({
    host: ‘填mailhost‘,
    secureConnection: true, // use SSL
    port: 465, // port
    auth: {
        user: ‘username‘,
        pass: ‘userpwd‘
    }
});

function ssl(){
    var mailOptions = {
        from: ‘"2017 New HandsUp Info" <SponsorChecker@intasect.co.jp>‘,
        to: ‘1598828268@qq.com‘,
        cc:‘hellomusic1993@qq.com‘,
        subject: mailTitle,
        text: mailContent,
        	
        attachments:[  
      {  
        filename : ‘HandsupInfo.png‘,  
        path: ‘HandsupInfo.png‘  
        }, {  
        filename : ‘HandsupInfo.html‘,  
        path: ‘HandsupInfo.html‘  
        },{  
        filename : ‘DownLoadUrl.txt‘,  
        path: ‘DownLoadUrl.txt‘  
        }
    ] 
    }
 
    return mailOptions;
}

stransporter.sendMail(ssl(), function(error, info){
    if(error){
        console.log(error);
    }else{
        console.log(‘Message sent: ‘ + info.response);
    }
});
}

  

Nodejs 发送邮件

标签:sharp   ret   .com   time   option   child   func   title   log   

原文地址:http://www.cnblogs.com/c-x-a/p/7791767.html

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