如何发送邮件而不使用电子邮件凭证通过nodemailer中的nodemailer npm?

我知道如何使用nodemailer发送邮件,但我使用的是电子邮件凭据,但我不想使用它。 有没有其他的方法发送邮件。

我的nodemailer代码片段是

var nodemailer = require('nodemailer'); // Not the movie transporter! var transporter = nodemailer.createTransport({ service: 'gmail', auth: { user: 'vikaskohli@email.com', // Your email id pass: 'password' // Your password } }); module.exports = { sendEmail: function sendMail(varhtml,vartext, varsubject,varfrom, varfrom_name,varto, varto_name, reply_to_email ) { //setup e-mail data with unicode symbols var mailOptions = { from: varfrom_name, // sender address // to: ['vikaskohli@email.com','vikaskohli1@email.com'], // list of receivers // to: ['vikaskohli@email.com,vikaskohli1@email.com'], // list of receivers // to: 'vikaskohli@email.com','vikaskohli1@email.com', // list of receivers to: varto, // list of receivers subject: varsubject, // Subject line text: vartext, // plaintext body html: varhtml // html body }; console.log(mailOptions); // send mail with defined transport object transporter.sendMail(mailOptions, function (error, info) { if (error) { return console.log(error); }else{ return console.log(info); } }); } } 

在上面的代码中,我也不会更改我的发件人名称。 如果我想从其他邮件发送像

vikaskohli3@gmail.com

但它会自动从我在这里使用凭据的邮件发送

vikaskohli@email.com

另外我尝试使用sendmail npm,他们不需要任何凭据,但它发送垃圾邮件文件夹中的邮件

我的sendmail代码片段

  var sendmail = require('sendmail')({silent: true}) sendmail({ from: 'vikaskohli@email.com', to: 'vikaskohli@email.com,vikaskohli1@email.com', subject: varsubject, // Subject line html: varhtml, attachments: [ ] }, function (err, reply) { console.log(err && err.stack) console.dir(reply) });