Configure email server for default virtual server for external connections

SYSTEM INFORMATION
OS type and version Ubuntu Server 22.04
Virtualmin version 7.1-1

Ok, so far so good. I can access email via Roundcube and I have configured webmail.gmcomputers.co.za to redirect to Roundcube in the virtual server templates as described elsewhere in this forum.
Now I would like to connect to my email server using Outlook 2021 and my Android phone from outside my internal network. So while I can connect Outlook to the email server perfectly using internal IP address, 192.168.0.xx, I simply cannot connect to the server from my external IP address. the URL mail.gmcomputers.co.za simply brings up my normal home website https://gmcomputers.co.za. DNS records are correctly set up at both my domain hosting provider ( I know this because at the moment I am using Kerio Mail server as my email server at home) and as far as I can see , also correctly configured in BIND.
so my question is, how do I configure Virtulamin so that I can connect to the Virtualmin email server using mail.gmcomputers.co.za, preferably without creating a new virtual server?

If mail.gmcomputers.co.za resolves (via DNS) to your external IP, the ports are open (SMTP, IMAP(s) etc) and Postfix is listening - you should be able to connect.

Since you mention internal IPs (192…) then I assume you would also need to have port forwarding in place on your router to forward traffic on those ports from the external IP to the server’s internal IP.

HIH

Dibs

Hi dibs, no as mentioned, mail.gmcomputers.co.za resolves to https://gmcomputers.co.za at the moment, which is what I do NOT want.
Port forwarding in my D-Link router is set up correctly. If I enable my Kerio mail server then mail.gmcomputers.co.za reloves correctly to Kerio, however, I want to do away with Kerio and use Virtualmin. Kerio is currently disabled.

@markdewet - do gmcomputers.co.za & mail.gmcomputers.co.za share the same IP address (external & internal)? i.e. the same server?

if you are talking about the URLs, yes they do.

I’m asking if you expect mail.gmcomputers.za to resolve to an IP address (DNS wise) and also expect gmcomputers.za to resove (DNS wise) to the same IP? Like with a Ping.

Well, yes, as that is how they are set up in BIND on Virtualmin. That was an automatic configuration done when installing Virtualmin

In which case the following still stands:

Unless I am missing something?

Dibs

p.s.

if you are using the same “server” for serving webpages (e.g. Apache) and also mail (say Postfix) then you will likely have 2 DNS entries. One for mail.gmcomputers.za and one for gmcomputers.za.

Because it’s the same server - typing both URLs into a browser will yield the same webpage. You could type both URLs into the servername fields in Outlook and it should still connect. Why? Because both addresses point to the same server.

Hopefully it makes sense.

I’m sorry, I really don’t know how to explain what I need any better. I simply want https://gmcomputers.co.za to go to my website and mail gmcomputers.co.za to be used to configure email settings. At the moment I don’t even know what the SMTP and IMAP names are, for goodness sake! I cannot even get something as simple as adding www to the front of my website URL to work!! I think honestly I just need to give up on this whole Virtualmin thing as it seems I am not experienced enough to use it. It’s a pity as it looks quite amazing. Thank you anyway for your assistance. I will look at other solutions for what I am trying to achieve.

@markdewet - see the “p.s.” on my earlier post.

mail.gmcomputers.co.za for both\either.

I did, and neither of those entries connect to the email server when configured in Outlook. Only when I inset the internal IP address can I connect to the email server.

Using Wormly SMTP test - attempting to connect to port 25 at 165.0.6.57 - it times out. Since your server\Virtualmin is behind a router with an internal (non-routable 192… IP address), this means that either no port forwarding exists or Postfix isn’t listening.

You say that you can connect to email from your internal network (192… IP address), perhaps check your Port Forward rules in the router and make sure all (SMTP, IMAP, IMAPs etc) traffic goes to the correct internal IP address of the server.

Port forwarding on all protocols, SMTP(25 and 465), IMAP, (993)definitely exists, I’ve just double-checked it. I’ve also checked with NETSTAT and ports are definitely listening.

Using Open Port Check Tool - Test Port Forwarding on Your Router and using 165.0.6.57 as the Remote Address with Port Number = 25 says

Port 25 is closed on 165.0.6.57.

Dibs

p.s.Maybe post up a screenshot of your port forwarding section on your router?

Dibs, it’s fine thank you really. I have wasted enough time on this already. I have an existing, working email server setup with Kerio Connect and my website is already set up on XAMPP for Windows, I was just hoping to consolidate all services into ne server. For now I will continue to use two separate Windows boxes. Sorry to say, but Windows just works.

A couple of things:

  1. Configuring a mail server correctly is very hard, and is definitely not plug-and-play. Even if you get a basic setup working – which I gather you’re having difficulty doing – the first time you send an email, your mail server will be blacklisted across the Internet because there’s a million settings that are not set up for you (DMARC, DKIM, SPIF, TLSA, etc etc, as well as a couple of dozen Postfix settings that do not come default) that must be configured absolutely perfectly or you will be flagged as a spammer. Documentation on how to set these things up is sparse, confusing, and often completely incorrect or out of date.

  2. After you think everything is set up right, you will be flagged as a spammer because various e-mail-checking services don’t always test everything essential. For years I was happy I scored 10/10 on the popular “newsletter” email tester until I figured out email security moved past the capabilities of that a long time ago. MX Toolbox is even worse. The best one I’ve found so far is https://en.internet.nl/ . But even that one doesn’t test everything.

  3. You don’t connect to Postfix to send and receive mail. You connect to Dovecot which communicates with Postfix. So that’s another thing to setup, but thankfully Dovecot is way easier.

  4. You need to have a DNS MX record configured that points to your mailserver. A DNS A record set to “www” will fix that problem too.

  5. Refer back to #1.

I realize you’ve already moved on from this project, so this is more for the next person looking into this. It’s certainly possible to set things up correctly, but you may labor under the assumption that everything’s working great, but 30% of your emails still end up in spam folders. Ever wonder why e-mails from people at Fortune 500 companies sent directly to you end up in spam? Their e-mail servers are not setup correctly.

Foul

@foulfoot,
I appreciate all the tips you are presenting and I agree that it is hard. However, I must stress that all my relevant records for my current domain, which is gmcomputers.co.za, are ALL set up correctly: DKIM, SPF, DMARC, MX and A, at my current hosting provider.
Having said that, Yes, documentation is indeed sparse and confusing. This is a source of much frustration for me, being a complete noob to Linux.
So again ,thank you for your input and yes I have moved on from this project. I am sticking with what I have currently installed, which is working perfectly.