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

201
Visualizações
Send Mail using nodemailer html as render jade in mail - nodeJS

Im getting following error while running

Error: Failed to lookup view "index" in views directory "C:\TFS\tambola-generator-master♂iews" at Function.render (C:\TFS\tambola-generator-master\node_modules\express\lib\application.js:580:17) at ServerResponse.render (C:\TFS\tambola-generator-master\node_modules\express\lib\response.js:1017:7) at C:\TFS\tambola-generator-master\server.js:104:7 at Layer.handle [as handle_request] (C:\TFS\tambola-generator-master\node_modules\express\lib\router\layer.js:95:5)

Code

app.get('/', function (req, res) {
  var tickets = tambola.default.generateTickets(1);
  
  tickets.map(t => t._entries).forEach(element => {
    element.filter(function(e){return e});
    var smtpTransport = nodemailer.createTransport(({
      host: 'smtp.zoho.com',
         //  secureConnection: true,         // use SSL
         port: 465,
         secure:true,
         requireTLS:true,
         auth: {
           user: 'xxx',
           pass: 'ccc'
         }
 }));
    data = element;
    config = {
      columns: {
        0: {
          width: 5   // Column 0 of width 1
        },
        1: {
          width: 5  // Column 1 of width 20
        },
        2: {
          width: 5   // Column 2 of width 5
        },
        3: {
          width: 5   // Column 2 of width 5
        },
        4: {
          width: 5   // Column 2 of width 5
        },
        5: {
          width: 5   // Column 2 of width 5
        },
        6: {
          width: 5   // Column 2 of width 5
        },
        7: {
          width: 5   // Column 2 of width 5
        },
        8: {
          width: 5   // Column 2 of width 5
        }
        

      }
    }
    

    var readHTMLFile = function(path, callback) {
      fs.readFile(path, {encoding: 'utf-8'}, function (err, html) {
          if (err) {
             callback(err); 
             throw err;
              
          }
          else {
              callback(null, html);
          }
      });
  };
  
 
  
  readHTMLFile(__dirname + '/Views/index.html', function(err, html) {
      var template = jade.compile(html);
      var replacements = {
           username: "John Doe"
      };
      var htmlToSend = template(replacements);
      var mailOptions = {
          from: 'xxx',
          to: 'ccccc',
          subject : 'test subject',
          html : htmlToSend
       };
      smtpTransport.sendMail(mailOptions, function (error, response) {
          if (error) {
              console.log(error);
              callback(error);
          }
      });
  });
    
  });
  
  var sequence = tambola.default.getDrawSequence();
  res.render('index',{tickets: tickets.map(t => t._entries)});
});

about 4 years ago · Juan Pablo Isaza
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