SMTP not working on internal network but outside its working on proxmox

rohan_sirohi

New Member
Oct 30, 2023
5
0
1
I have set up SMTP on Proxmox using Mailcow, and everything is working fine.Only one issue: I am not able to use that SMTP on the Proxmox server. itself internally. For example, if I create another machine on the proxmox server and set up a Node project that uses SMTP, my Mailcow SMTP will not work {other SMPT's working fine like gmail or sendgrid}. However, if I use the same Node project on another server or locally, my Mailcow SMTP works fine.It seems SMTP is not working internally within the Proxmox server where SMTP is set up.

Is there any possible solution for this? DNS Issues?

If required additional information let me know I will provide.
 
Code:
const nodemailer = require('nodemailer');

let transport = nodemailer.createTransport({
  host: 'mail.mydomain',
  port: 587,
  auth: {
    user: 'exceptions@mydomain',
    pass: '**********'
  },
  tls: {
    rejectUnauthorized: false,
  }
});

const message = {
  from: 'exceptions@mydomain', // Sender address
  to: 'myexternalmail-id',     // List of recipients
  subject: 'Mail works',       // Subject line
  text: 'We know credentials work' // Plain text body
};

transport.sendMail(message, function (err, info) {
  if (err) {
    console.log(err);
  } else {
    console.log(info);
  }
});

This is a simple mail tester I am using from one of my Proxmox machines (a .NET Project VM).

Code:
── Proxmox Server (100.160.231.12)
   ├── NGINX Container (192.168.15.11)
   ├── Mailcow Container (192.168.15.12)
   ├── .NET Project VM (192.168.15.13)
   └── Node Project Container (192.168.15.14)

My setup: `mail.mydomain` is set up on the Mailcow machine, but NGINX is running on another container. This entire server is running behind NAT.

Below are the results from different configurations tested in the SMTP tester:

When using Host - `mail.mydomain` and port 587:

Code:
PS C:\Users\Administrator\Desktop\smtp> node .\index.js
Error: connect ECONNREFUSED 100.160.231.12:587
    at TCPConnectWrap.afterConnect [as oncomplete] (node:net:1606:16) {
        errno: -4078,
        code: 'ESOCKET',
        syscall: 'connect',
        address: '100.160.231.12',
        port: 587,
        command: 'CONN'
    }

If I am using Host - `192.168.15.12` and port 25:

response: '554 5.7.1 <myexternalmail-id>: Relay access denied',

When using Host - `192.168.15.12` and port 587:

Success - I am able to receive email.

However, when using Host - `mail.mydomain` and port 587 on other servers anywhere in the world, it works fine.
 

About

The Proxmox community has been around for many years and offers help and support for Proxmox VE, Proxmox Backup Server, and Proxmox Mail Gateway.
We think our community is one of the best thanks to people like you!

Get your subscription!

The Proxmox team works very hard to make sure you are running the best software and getting stable updates and security enhancements, as well as quick enterprise support. Tens of thousands of happy customers have a Proxmox subscription. Get yours easily in our online shop.

Buy now!