Home » HowTo » Configure hMailServer with external Gmail SMTP

Configure hMailServer with external Gmail SMTP

The steps to configure hMailServer is a very simple and straightforward process. In this case we just follow up from the steps as per install hMailServer in the previous article.

What we’ll add in this case is the option to use an external SMTP Server and in this case a Gmail SMTP Mail server.

In my home lab I will use an external gmail account to send email notifications from the apps running my home lab. Typically these would be email notifications about:

  • Backup job stutus
  • Monitoring and Alerts triggers
  • Primary and Backup Storage status
  • and many more..

So let’s take a quick look on how to configure hMailServer.

Configuration steps with Gmail SMTP

First of all we need to connect to the Mail Server using the hMailServer Administrator console.

domalab.com Configure hMailServer Connect

Let’s provide the password chosen at the installation time.

domalab.com Configure hMailServer administrator password

the main console will greet us with a welcome and the option to add a Domain. We can create multiple domains. This is useful for testing scenarios. For example trying to reproduce an environment with a local, extenal and DMZ zone. Each one of them can be sitting on different domains. Assuming we need to run or test an application sending/receiving emails based on different domain names this is pretty interesting.

All the solutions related to Network Access Control (NAC), Host Intrusion Prevention (HIPS) and similar can be tested as well in a home lab with the help of hMailServer. We can setup multiple domains and choose also a default one.

Let’s make sure the DNS name resolution with FQDN names and pertinent MX records are created accordingly.

domalab.com Configure hMailServer getting started

Let’s add a new domain name as per screenshot below.

domalab.com Configure hMailServer add domain

As soon as the new domain is created we can now create Accounts recipients, aliases and distribution lists. Very interestingly we can also add extra features like email signatures and email limits.

Also let’s make sure the Domain configuration is “Enabled”.

domalab.com Configure hMailServer domain name

At this point we are ready to create basic email recipients: Info account in this case.

domalab.com Configure hMailServer create recipient

And another one for the webmaster.

domalab.com Configure hMailServer add recipient

Next is to move to the Settings > Protocol > SMTP section as per screenshot below.

domalab.com Configure hMailServer enable SMTP

Let’s move to the “Delivery of e-mail” tab to configure the number of retries and time between such retries.

More importantly from here we can specify the Gmail SMTP settings:

  • Server: smtp.gmail.com
  • Port: 587
  • Username: gmail account
  • Password: gmail account password

Some external SMTP servers might require the local hostname to verify from which server the email has been sent.

Once completed let’s click on Save to amend changes.

domalab.com Configure hMailServer Gmail SMTP relayer

If the hMailServer is installed on a machine with multiple addresses let’s make sure to add local IP address where to bind the hMailServer service. Let’s leave the rest of the settings as per screenshot below.

domalab.com Configure hMailServer local IP

Just for initial testing we can disable the “Auto-ban” feature should we experience invalid logons. Let’s enable it back once completed with the testing.

domalab.com Configure hMailServer disable auto-ban

Before proceeding let’s run some disgnostic tool. We can find them in the Utilities section. the first one is the MX-query to make sure the FQDN name can be fully resolved. As the screenshot is showing there are the IPv4 and IPv6 (disabled in my home lab) addresses.

domalab.com Configure hMailServer MX query

Another interesting tool is the Disgnostic which runs a full test against a public Mail Server hosted by hMailServer website itself. Pretty handy!

domalab.com Configure hMailServer diagnostic

We can run the same test against smtp.gmail.com and check the results.

Another interesting and quick one is to simply use the telnet client to see if there is any network port blocked. For example:

telnet smtp.gmail.com 587

We are now ready to test our application to send email notifications. In my case I will start with Veeam Backup & Replication to test jobs email notifications. As soon as the test email is sent we can see from the SMTP Status tab the number of processed messages and the number of open sessions. The stats also show other useful info POP3 and IMAP protocols together potential viruses or spam detected.

From the “Delivery queue” tab in fact we can see the test message generated by Veeam Backup and Replication Server.

If we now click on the message we can see the content and the various metadata details of the email notification. As we can see from the screenshot the internal user called “info” sends a message to vhomelab gmail account. Then the test email notification will be visible and downloadable from the Gmail server using either a POP3 or IMAP client.

This concludes a quick article on how to configure hMailServer to relay email messages to an external SMTP server like Gmail. There’s a lot more we can do with hMailServer and we’ll cover more configurations topics in dedicated articles with greater detail.


About the author

Michele Domanico

Passionate about Virtualization, Storage, Data Availability and Software Defined Data Center technologies. The aim of Domalab.com is sharing with the Community the knowledge and experience gained with customers, industry leaders and like minded peers. Always open to constructive feedback and new challenges.


Click here to post a comment

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

    • Thanks for your kind words Laura and glad it was helpful. More articles will follow around SMTP and other mail protocol and in particular with Office 365.

      Kind regards,

  • Michele, thank you posting this thorough stepping through of this process, as the hmail documentation simply does not explain adequately. Great job. You’ve saved me much frustration!

    • Hi Linson,

      thanks for your comment. In my case, this setup didn’t require an MX record as sending the email to outside domains. It is indeed needed (or best practice) when external domains send email to your own or chosen domain. In this case the MX record needs to be “published” by your DNS Registrar (or ISP) as name resolution to your domain only is not sufficient. With multiple domains it is also possible to have multiple MX records. Hope this helps.

      Kind Regards,

  • Hi.. Good and Helpful post.. One question:- since you have used gmail account, whether after sometimes gmail blocks the email ID or it continues to work as it was..I am planning to use the same method in my Network Monitoring System software which would generate alert frequently. And frequent use of gmail ID from local domain would sometimes block the gmail.

    Thanks and Regards
    Shankar M V

    • Hi Shankar,
      Thanks for your comment. I have not seen this behavior in my home lab where I use a valid TLP domain. Just wondering if there is a gmail policy/rule monitoring this? I guess if local domain is a publicly registered one maybe there are less restrictions with SMTP relay or simply put too many relay requests have been generated. Just out of curiosity how many emails are generated?

      Kind Regards,

  • thanks for the tutorial
    how about how to configure gmail to send to other corporate mails

    • Hi Kingsley Ofori,

      thanks for your comment. SMTP relay is a Mail Transfer Agent (MTA) you would use when transferring large amount of emails (eg. newsletters to thousands of users in one go). Instead of using your internal SMTP server, you can leverage instead a trusted public one. This means the target recipients are not configured from the SMTP Relay server (Gmail in this case) but directly in the “To” field when composing the email message. Hope this helps.


  • Can we do this changes in silent mode
    Can we update/append in registry or file to replicate the same changes, instead of doing manully

    • Hi JP,
      not that I’m aware of. AFAIK settings and config are stored in the chosen database. What is the use case for this? Multiple installs of same config with different parameters would be too long compared to the actual install and custom config possibly. Or probably easier to have a single one with multiple domains.


Subscribe to Blog via Email

Enter your email address to subscribe to this blog and receive notifications of new posts by email.

Browse articles

June 2023

Articles by Category


error: Content is protected !!
%d bloggers like this: