In this how-to, I will be describing how to set up hMailServer for a slightly different purpose. Rather than being a normal mail server, it will be performing more local duties in allowing shared access to a single ISP-provided email account. Starting from a single PC running Thunderbird to access a POP account on the ISP, we'll finish with shared email folders that any client in the home network can access simultaneously, without losing the existing emails.
When a home network grows from a single PC connected to the internet to several machines connecting through a router, it can be a pain to have a single PC nominated as the "email reading" PC. I might want to access email from any of the connected PCs on the network. There is always webmail, I suppose, but it wouldn't be possible to get at the existing emails on that, and is never really as convenient as client-side access, and the limitations on storage space and bandwidth may be restrictive.
The solution, then is to run an IMAP server on one of the PCs, have that access the POP account on the ISP, and have any client on the home network access the IMAP folders to get at the email. The existing emails can be easily migrated into the new IMAP folders for all clients to access.
First, download and install hMailServer on a PC that will be most often turned on. If you have one that is always turned on, so much the better, as mail will only be available to the other PCs in the network while it is on.
After downloading and installing hMailServer, the next step is to add a domain. It isn't going to be acting as a mail server for that domain, so for convenience enter the ISP POP account server as the domain. For this example I'm going to assume the POP account is email@example.com
. So, the domain would be "isp.com". (Note, in this example hMailServer is not being used for SMTP. If, for some reason, you want to route your outgoing mail through hMailServer too, rather than directly to your ISP, then you should use the "example.com" domain instead.)
Next, add a user to that account, which again for convenience, I'm going to keep the same as the POP account username, which would make it "username". The account therefore becomes "firstname.lastname@example.org".
Once the account is added, go to the External Accounts tab and add a new External Account. This will be the ISP POP account, so enter all the details for it there, the same as they are currently configured in the email client. I will assume it is Thunderbird, for this example. Leave the option to delete mails on the server to "Don't delete" for the time being, to avoid anything falling between the cracks while we're setting things up.
Next, expand the "Settings" node and click on the "Protocols" node. Uncheck SMTP and POP servers, as we won't be using those, just leaving the IMAP server checked.
Now, to set up IP Ranges. These can be found under the "Settings\Advanced\IP Ranges" node. Select the existing one called Internet, and uncheck everything - we don't want this server to be internet accessible at all. Click on the "IP Ranges" node again, and Add a new range. Give it a name like "Home Network", and the IP range of your network.
This will usually be something like 192.168.1.0 to 192.168.1.255. If you aren't sure, then go to a command prompt and type "ipconfig" to discover your IP address. For most home networks set up to access the internet through a router, it should start with 192. The range would then usually be the first 3 bits of the IP address, with 0 to 255 for the last bit. If your network setup is more unusual, then determining your range is outside the scope of this howto. As a last resort, you could leave it as an internet range of 0.0.0.0 to 255.255.255.255, and rely on the firewall and NAT to prevent access from external connections.
In any case, once the new range is in place, give it a priority of 25 (shouldn't matter, as there aren't other ranges anyway), then check all the checkboxes. Most of them won't apply anyway, as hMailServer won't be acting as a mail server, but it won't do any harm to have them checked. At the least, the IMAP checkbox must be checked.
Now we must open the port in the local firewall, if there is one. Port 143 TCP must be opened. If you are using Windows Firewall, this can be done by going to Control Panel, then Windows Firewall, clicking on the Exceptions tab, then clicking the Add Port button. For the name, enter something descriptive like "IMAP", then for Port number enter "143", and make sure TCP is selected. Click the "Change Scope" button, and choose the "My network (subnet) only" option. After OK'ing all the way out, the port should now be open. If you are using any other local firewall, then consult its documentation on how to open a port.
The next step is to configue Thunderbird to use the new account. To do this, you will need to know your IP address on the internal network. This can be found using the ipconfig command as I described above. Sometimes home networks are set up to assign IP addresses by DHCP, which means your IP address won't be fixed. In this case you should give the PC that has hMailServer on it a fixed IP address, which is out of the scope of this howto. There are other guides on how to do this available, though.
To configure Thunderbird to use the new account, choose to create a new Mail account, enter your name and email address (email@example.com
) as usual, then select "IMAP" as the type of incoming server. As the name of the incoming server, enter the IP address of the PC running hMailServer, 192.168.1.201, for example. For the username, enter your email address (firstname.lastname@example.org
) again. Give the account a name, and you're done. This should be done on every PC you want to be able to access the email on. If you use Junk mail controls, then make sure these are set up for the new IMAP account in the way you like them.
To improve IMAP performance in Thunderbird, it can also be worthwhile going to Options, Advanced, General, and clicking on Config Editor. Enter "mail.imap.fetch_by_chunks" into the filter, then double click on it to set it to "false".
If you are setting up a new Thunderbird installation you will also be asked for the SMTP server settings. These should be entered just as given to you by your ISP, or copied from the existing Thunderbird installation you were using for mail.
It is usually worth going to Account Settings for the new IMAP account and making sure the Copies & Folders settings are set up right. I would recommend that any copies you keep, such as drafts, and sent mails, go in folders on the IMAP account, rather than Local Folders, so that they are shared. I would also recommend setting the "Check for new messages every" setting under "Server Settings" to be the same value as you set hMailServer to check for external mail when setting it up.
The next step is to migrate your existing mail into the shared IMAP folders. To do that, go to the PC that has the original ISP POP email account in Thunderbird on it. Go to Account settings, and for the original ISP POP email account, under "Server Settings", uncheck the "Check for new messages" checkboxes. Receiving new mail will just get in the way, until migration is complete. Finally, drag and drop each of your mail folders from under your existing account to the under new IMAP account. I would recommend holding down the Ctrl key while doing so, to copy instead of move, just in case anything goes wrong half way through. Don't forget to do your Sent folder too, and any other folders that need to be shared.
Copying all the mail across will probably take a long time, and suck up CPU cycles like a monster.
Once it is done, and you've checked you can access the mail in the IMAP folders, you can delete the original ISP POP account. If you had it set to deliver mail to Local Folders, you can also delete all the mail you've just copied across out of them too. Unfortunately Local Folders can't be removed, but can be collapsed and ignored.
The last step is to go back to hMailServer, go to "Domains\isp.com\Accounts\email@example.com", and select the External Accounts tab. Double click on the external account, and change the Delete messages setting to "Delete messages immediately".
Once this has been set up, your mail should be accessible and synchronised across all clients on your home network, even if they are using different mail programs. Note that it will not share your address book, you will have to do that separately.
The only disadvantage of this system that I have found is that the Get Mail button no longer actually gets mail; there is no way to force a check of the ISP POP email account sooner than the interval specified. This can be frustrating if you are chatting with someone who sends you something by email and expects you to receive it immediately.
I hope someone finds this helpful, as when I was looking for information on how to share email folders across a network, I would really like to have found something like this. If more experienced hMailServer or network people would like to contribute improvements or suggestions, those would be welcome too!