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

995
Visualizações
No recipients found in nodemailer

I am trying to send a mail using nodemailer. I think i have given all the mailOptions correctly. As i have confirmed that by printing mailOptions to the console.

And i have also checked auth and user. They are correct and well imported.

But still i am getting no recipient defined error. Where is the problem?

enter image description here

Here is the entire sendEmail function

function sendEmail(payload) {
var fromEmail = config.cfg.smtp.fromEmail;

console.log(fromEmail);
var toEmail = payload.to;
var subject = payload.subject;
var content = `<p>Greetings! your order is on the way. Order details are</p>`;
let smtpTransport = nodemailer.createTransport({
  service: "gmail",

  auth: {
    user: config.cfg.smtp.auth.user,
    pass: config.cfg.smtp.auth.pass,
  },
});
// setup email data with unicode symbols
let mailOptions = {
  from: fromEmail, // sender address.  Must be the same as authenticated user if using Gmail.
  to: toEmail, // receiver
  subject: subject, // subject
  html: content, // html body
};

return new Promise(function (resolve, reject) {
  smtpTransport.sendMail({ mailOptions }, function (err, data) {
    console.log(mailOptions)

    if (err) {
      console.log("your mail could not be sent");
      return reject(err);
    }
    resolve(data);
    console.log("Your mail is sent");
  });
});

}

over 4 years ago · Santiago Trujillo
1 Respostas
Responde à pergunta

0

You are sending your mailOptions inside another object. Try the following instead.

return new Promise(function (resolve, reject) {
  smtpTransport.sendMail(mailOptions, function (err, data) { // mailOptions is already an object.
    console.log(mailOptions)

    if (err) {
      console.log("your mail could not be sent");
      return reject(err);
    }
    resolve(data);
    console.log("Your mail is sent");
  });
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