Trying to send mail using nodemailer, got "outside" as an answer (means mail was not sent). No error, or anything that can be catched
index.js
app.get('/test', async (req, res) => {
  const email = require("./core/email");
  var mail = new email();
  var msg = await mail.sendMail();
  res.send(`${msg}`);
})
email.js
var nodemailer = require('nodemailer');
class email {
  transporter;
  mailOptions;
  constructor() {
    this.transporter = nodemailer.createTransport({
      port: 1025,
    });
    this.mailOptions = {
      from: '[email protected]',
      to: '[email protected]',
      subject: 'Confirm Email',
      text: 'Please confirm your email',
      html: '<p>Please confirm your email</p>'
    };
  }
   async sendMail() {
    await this.transporter.sendMail(this.mailOptions, (error) => {
      if (error) {
          return error;
      }
      return 'Sent:';
    });
    return 'outside';
  }
}
module.exports = email;
docker-compose.yml
version: "3"
services:
  mailhog:
    image: mailhog/mailhog
    ports:
      - 1025:1025 # smtp server
      - 8025:8025 # web ui
docker ps shows mailhog container, and web UI works fine in http://localhost:8025/
CONTAINER ID   IMAGE                     COMMAND                  CREATED        STATUS        PORTS                                            NAMES
f437dd5c7f09   test_test-app             "docker-entrypoint.s…"   16 hours ago   Up 16 hours   0.0.0.0:3000->3000/tcp                           test_test-app_1
d1c3f6ca1a6a   mailhog/mailhog           "MailHog"                16 hours ago   Up 16 hours   0.0.0.0:1025->1025/tcp, 0.0.0.0:8025->8025/tcp   test_mailhog_1
2ff9a562c344   mongo                     "docker-entrypoint.s…"   16 hours ago   Up 16 hours   27017/tcp                                        test_mongo_1
				
                        
Make sure to add the host, the host should be the docker service name stated in the docker-compose file.
docker-compose file: