Skip to content

Instantly share code, notes, and snippets.

@raelgc
Last active April 9, 2024 18:58
Show Gist options
  • Star 81 You must be signed in to star a gist
  • Fork 17 You must be signed in to fork a gist
  • Save raelgc/6031306 to your computer and use it in GitHub Desktop.
Save raelgc/6031306 to your computer and use it in GitHub Desktop.
Setup a Local Only Email Server (Windows Only)

Setup a Local Only Email Server (Windows Only)

1 - Install hMailServer

Download hMailServer from here: http://www.hmailserver.com/index.php?page=background_download_file&downloadid=207.

  • In setup, select internal db engine.
  • Now you have a service called hMailServer and an administration program on the Windows start menu (hMailServer Administrator).

2 - Create a domain

  • Open hMailServer Administrator program.
  • Click on "Domains" and then "add domain".
  • At "domain name" put a fake domain to test. Use "localhost.com" (without the quotes): hMailServer requires a fully qualified domain, so, we cannot use @localhost.
  • Make sure to add your domain (localhost.com) to hosts file: C:\windows\system32\drivers\etc\hosts

3 - Change server name

  • Expand Settings > Protocols > SMTP -> Delivery of e-mail
  • At "Host name" put "localhost" (without the quotes).
  • Check if TCP Port is 25.

4 - Create an account

  • Go to "Domains", click on the created domain, and then click on "accounts", then "add account".
  • At "address", create your account name, here I use "rael" (without the quotes), and put a password.
  • Change "Administration level" to "Server".

5 - Configure "catch-all" address

  • Enabling this, you can use any email address ending with you fake domain. Example: here, my unique account is rael@localhost.com. But while testing systems, I can use any address like joe@localhost.com, foo@localhost.com, etc, because all will be redirected to rael@localhost.com
  • Open "Domains", click on your domain, open Advanced tab, fill field "catch-all address" with account created on previous step.

6 - Configure an Email client

  • At Windows, you can use Windows Live Email (http://explore.live.com/windows-live-essentials-other-programs?T1=t2).
  • Of course, you can use any email client.
  • While configuring
    • Incoming Server is POP3, and the username is the full email address (like rael@localhost.com), and the password is raw text (no encrypt).
    • POP3 and SMTP server are "localhost" (without the quotes).
    • Outgoing server do not require authentication.
  • Don't use the email client and the hMailServer Administration application at the same time!
@Philosoraptor
Copy link

Very helpful, thanks.

@anne052486
Copy link

Is it applicable if we have static IP in workstation?

@maximousblk
Copy link

@kiumbe try editing the host file of every pc on your lan network

@charlottetan
Copy link

Ran into issues getting the Windows Mail client to work, got an error code 0x8007139f. Turns out it's because the Mail was missing a couple of privacy permissions. I turned on permissions for Email via the Settings app and worked for me after.

More info: https://www.reddit.com/r/Windows10/comments/89geut/mail_calendar_app_not_letting_me_add_an_account/

@diegombt
Copy link

diegombt commented May 30, 2020

Thanks man, great Gist!

@johntsunami
Copy link

Can you add example scripts on how to add attachments etc?

@ptrqww
Copy link

ptrqww commented Feb 16, 2023

Please, what exactly should I write in the hosts file?
Just
localhost.com ? or 127.0.0.01 licalhost.com

Thank you )

What I get in status is "localhost" is currently banned in the ip ranges"...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment