Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

663
Visualizações
How to send mail without using email-credentials via nodemailer npm in nodejs?

I know how to send mail using nodemailer but I am using email credentials of that, but I don't want to use that. Is there any other method of sending mails.

My nodemailer code snippet is

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);
           }
       });


   }

}

In the above code, also I don't change my sender name. If I want to send from other mail like

vikaskohli3@gmail.com

but it automatically send from that mail for which I have use credentials here

vikaskohli@email.com

Also I tried using sendmail npm, they don't need any credentials but it send mail in the spam folder

My sendmail code snippet

 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)
  });
over 4 years ago · Santiago Trujillo
1 Respostas
Responde à pergunta

0

I use sendmail like your bottom code, and it works fine for me. Perhaps the reason it's going to spam is because your settings in the email provider. Most likely the email you chose as sender (@email.com) seems like a spam to that service provider or your settings.

over 4 years ago · Santiago Trujillo Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda