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.
Let’s provide the password chosen at the installation time.
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.
Let’s add a new domain name as per screenshot below.
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”.
At this point we are ready to create basic email recipients: Info account in this case.
And another one for the webmaster.
Next is to move to the Settings > Protocol > SMTP section as per screenshot below.
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.
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.
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.
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.
Another interesting tool is the Disgnostic which runs a full test against a public Mail Server hosted by hMailServer website itself. Pretty handy!
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.