how to send emails using nodejs


var nodemailer = require('nodemailer');

var transporter =
nodemailer.createTransport({
  service: 'gmail',
  auth: {
   
user: 'youremail@gmail.com',
   
pass: 'yourpassword'
  }
});

var mailOptions = {
 
from: 'youremail@gmail.com',
 
to: 'myfriend@yahoo.com',
  subject: 'Sending Email using Node.js',
  text:
'That was easy!'
};

transporter.sendMail(mailOptions,
function(error, info){
  if (error) {
    console.log(error);
  } else {

   
console.log('Email sent: ' + info.response);
  }
});

www.codegrepper.com
www.stackoverflow.com

how to rename zip file nodejs


var AdmZip = require('adm-zip');

//create a zip object to hold the new zip files
var newZip = new AdmZip();

// reading archives
var zip = new AdmZip('somePath/download.zip');
var zipEntries = zip.getEntries(); // an array of ZipEntry records

zipEntries.forEach(function(zipEntry) {
var fileName = zipEntry.entryName;
var fileContent = zip.readAsText(fileName)
//Here remove the top level directory
var newFileName = fileName.substring(fileName.indexOf("/") + 1);

newZip.addFile(newFileName, fileContent, '', 0644 << 16);
});

newZip.writeZip('somePath/upload.zip'); //write the new zip

www.codegrepper.com
www.stackoverflow.com