Nodemailer: Trying to send any email causes an 'Unexpected socket close'

Created on 14 Jan 2021  Â·  4Comments  Â·  Source: nodemailer/nodemailer

Please fill the following questionnaire about your issue:

  1. What kind of issue are you reporting?
  2. [x] A bug in Nodemailer
  3. [ ] A bug in a plugin of Nodemailer (eg. issues with nodemailer-sendgrid)
  4. [ ] Feature request
  5. [ ] Looking for help to resolve some kind of problem with Nodemailer

  6. Are you listed as a sponsor of Nodemailer project (see Sponsors button above)?

  7. [ ] Yes. Sponsors get priority support
  8. [x] No. Unless it is a bug in Nodemailer you might find support from public forums like StackOverflow.

  9. State your problem here:
    Trying to send any email causes an error to throw. Using the example in the documentation throws it.

"use strict";
const nodemailer = require("nodemailer");

// async..await is not allowed in global scope, must use a wrapper
async function main() {
  // Generate test SMTP service account from ethereal.email
  // Only needed if you don't have a real mail account for testing
  let testAccount = await nodemailer.createTestAccount();

  // create reusable transporter object using the default SMTP transport
  let transporter = nodemailer.createTransport({
    host: "smtp.ethereal.email",
    port: 587,
    secure: false, // true for 465, false for other ports
    auth: {
      user: testAccount.user, // generated ethereal user
      pass: testAccount.pass, // generated ethereal password
    },
  });

  // send mail with defined transport object
  let info = await transporter.sendMail({
    from: '"Fred Foo 👻" <[email protected]>', // sender address
    to: "[email protected], [email protected]", // list of receivers
    subject: "Hello ✔", // Subject line
    text: "Hello world?", // plain text body
    html: "<b>Hello world?</b>", // html body
  });

  console.log("Message sent: %s", info.messageId);
  // Message sent: <[email protected]>

  // Preview only available when sending through an Ethereal account
  console.log("Preview URL: %s", nodemailer.getTestMessageUrl(info));
  // Preview URL: https://ethereal.email/message/WaQKMgKddxQDoou...
}

main().catch(console.error);

the result I get is

Error: Unexpected socket close
    at Timeout._onTimeout (/home/nodemailer-test/node_modules/nodemailer/lib/smtp-transport/index.js:189:31)
    at listOnTimeout (internal/timers.js:549:17)
    at processTimers (internal/timers.js:492:7)

Most helpful comment

This should be resolved now. Somehow required disk mount stopped working.

All 4 comments

Also running into this. Would be nice if https://status.ethereal.email/ detected this sort of down time.

Also seeing this! Totally appreciate the free service though so not complaining—just confirming. Also I agree with @kiancross — it'd be great if the status page accurately reflected this type of issue.

i have de same error, and I was breaking my head to solve it until I came here

This should be resolved now. Somehow required disk mount stopped working.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

RobertoDieguez picture RobertoDieguez  Â·  4Comments

uiteoi picture uiteoi  Â·  5Comments

tegarkurniawan picture tegarkurniawan  Â·  3Comments

curlynux picture curlynux  Â·  5Comments

abhishekdgeek picture abhishekdgeek  Â·  5Comments