Create an Email Server on Windows (WAMP, hMailServer & Roundcube)

A local email server is an email server that is installed on a local machine and is responsible for the delivery of emails using common email protocols. Learn in this post how to set up an email server on Windows with a webmail interface integration.

Create an Email Server on Windows

Having a local email server simplifies the web development process by making email testing easy on local computer. This post demonstrates how to set up a self-hosted email system on Windows using hMailServer as an email client combined with Roundcube as a webmail interface. Before we begin, we will need to download the email server and webmail interface from the following links:

  1. Download hMailServer
  2. Download Roundcube
 

What is hMailServer?

It is an open-source, free email server for Microsoft Windows that handles mail delivery on a local machine. It comes with support for IMAP, POP3, SMTP, and other additional features that an email server should have.

 

What is Roundcube?

It is an open-source webmail client written in PHP that uses AJAX on the client side. This means it requires JavaScript to be enabled on the client browser. It comes with many UI skins, multi-language support, and a lot more.

 

How to Set Up a Windows SMTP Server?

The configuration of an email server on Windows involves installing and configuring hMailServer and Roundcube interface. Roundcube will be serving as a webmail interface, meaning we will need to access it through web browser. So we also need to install WAMP and create a virtual host for our webmail interface as well as for main domain for hMailServer in the httpd-vhosts file. The file can be found at the following location on Windows.

C:\wamp\bin\apache\apache2.4.51\conf\extra\
<VirtualHost *:80>
DocumentRoot "c:/wamp/www"
ServerName example-domain.com
ServerAlias example-domain.com
</VirtualHost>
<VirtualHost *:80>
DocumentRoot "c:/wamp/www/roundcube"
ServerName mail.example-domain.com
ServerAlias mail.example-domain.com
</VirtualHost>

We will also need to add entries to the Windows hosts file for the above virtual hosts. The Windows' hosts file can be found in c:\windows\system32\drivers\etc\ on Windows.

Assuming you already have WAMP installed and running, let's move to the hMailServer installation and configuration, and the Roundcube webmail interface setup. After downloading both, follow these steps to first install hMailServer.

 

Install & Configure hMailServer on Windows

  1. Run the installation setup of hMailServer.
  2. Click "Next".
  3. Click the checkbox "I accept the agreement" and click "Next".
  4. Set the destination folder where hMailServer will be installed and click "Next".
  5. We need both components, so check both available components and click "Next".
  6. Click the checkbox "User built-in database engine" and click "Next".
  7. Click "Next".
  8. Set the password, we will need this password to connect to the server, click "Next".
  9. After all of the above steps, click "Install" to continue installation.
After the installation has completed, launch hMailServer and connect. It will prompt for the password we entered during installation. Enter the password and connect.

1. On the welcome screen, click "Domains" on the left side navigation panel and then click on "Add" from the top-right buttons.

Create an Email Server on Windows WAMP-01

2. Enter a domain name of choice; I am using example-domain.com for this post, click "Save".

Create an Email Server on Windows WAMP-02

3. Click "Accounts" on the left-side navigation panel and then click "Add" on the top-right buttons.

Create an Email Server on Windows WAMP-03

4. Enter the email address and password for the account and then click "Save".

Create an Email Server on Windows WAMP-04

Configure Roundcube on Windows

1. Create a directory roundcube inside www, and extract the Roundcube files that we downloaded to this directory.
2. Open a browser and enter localhost/roundcube/installer URL.
3. On the first screen, we will see the status of the environment. Normally, it should show an "OK" status for all configurations at this step; we just have to click "Next".

Create an Email Server on Windows WAMP-05

4. On the following step page, we do not have to change anything; just enter the database host, database name, username and password for the database in the "Database Setup" section. Also, enter the host for the SMTP server in the "SMTP Settings" section. Click "Create Config".

Create an Email Server on Windows WAMP-06

5. This is the final step; we will see the "Test Config" page. Click the button "Initialize Database", and that's it.
Now open "mail.example-domain.com" in any browser, and we will see the following page.

Create an Email Server on Windows WAMP-07

Enter the email address and password we configured in hMailServer and log in. We will see the following page, from where we should be able to log in to our mailbox account.

Create an Email Server on Windows WAMP-08

All Done! We just created a Windows SMTP server with a webmail interface on our localhost. We can now create multiple mailboxes and test the email delivery on localhost.


NOTE: If you are still having issues, make sure you followed all the steps carefully. After that, consider adding an exception for hMailServer in the firewall or changing the "Require SMTP Authentication" setting in the hMailServer Administrator Panel ➞ Settings ➞ Advanced ➞ IP Ranges ➞ My Computer.