Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

925
Views
Nodemailer Ethereal emails are not deliver to the gmail

I'm trying to send emails using the following function using express js server. It seems to be working fine. But when I send email it’s not visible in my gmail inbox or spams.

Function i used:

const transporter = nodemailer.createTransport({
    host: 'smtp.ethereal.email',
    port: 587,
    auth: {
        user: 'leo.skiles74@ethereal.email',
        pass: 'BJkKV41tNZNBmMkkCw'
    }
});

function SendEmail(email,subject,text,html) {
    return new Promise(async (resolve, reject) => {
        try {
            let info = await transporter.sendMail({
                from: "leo.skiles74@ethereal.email",
                to: email,
                subject: subject,
                text: text,
                html:html
            })
            resolve(info)
        } catch (error) {
            reject(error)
        }
    })
}

Response received:

{
  "accepted": [
    "gayantaanus@gmail.com"
  ],
  "rejected": [],
  "envelopeTime": 759,
  "messageTime": 506,
  "messageSize": 596,
  "response": "250 Accepted [STATUS=new MSGID=YpXX5N-8J14cOJVHYpXjvw93heVfMHMGAAAAA4okSTkzId5ci.tBPvM2244]",
  "envelope": {
    "from": "leo.skiles74@ethereal.email",
    "to": [
      "gayantaanus@gmail.com"
    ]
  },
  "messageId": "<91f5d48e-a363-b59a-d47b-c44736e49c43@ethereal.email>"
}

But not delivered to gmail. How to fix and explain to me the reason ?

over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

This is the way:

const nodemailer = require("nodemailer");
nodemailer.createTestAccount((err, account) => {
 if (err) {
console.error("Failed to create a testing account. " + err.message);
return process.exit(1);
}
console.log("Credentials obtained, sending message...");
let transporter = nodemailer.createTransport({
host: account.smtp.host,
port: account.smtp.port,
secure: account.smtp.secure,
auth: {
  user: account.user,
  pass: account.pass,
},
});
 let message = {
from: "Sender Name <sender@example.com>",
to: "Recipient <recipient@example.com>",
subject: "Nodemailer is unicode friendly ✔",
text: "Hello to myself!",
html: "<p><b>Hello</b> to myself!</p>",
};
transporter.sendMail(message, (err, info) => {
  if (err) {
    console.log("Error occurred. " + err.message);
  return process.exit(1);
}
console.log("Message sent: %s", info.messageId);
console.log("Preview URL: %s", nodemailer.getTestMessageUrl(info));
});
});
over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!