How to run mail server on localhost on windows system

Running a mail server on localhost on a Windows system can be a bit complex, but I'll guide you through the process. We'll use OpenSMTPD, a popular open-source mail server, and PostfixAdmin, a web-based interface for managing email accounts.

Prerequisites:

  1. Windows 10 or later (64-bit)
  2. Administrator privileges
  3. A static IP address (e.g., 127.0.0.1 for localhost)
  4. A domain name (e.g., example.local)

Step 1: Install OpenSMTPD

  1. Download the OpenSMTPD installer from the official website: https://opensmtpd.org/
  2. Run the installer and follow the prompts to install OpenSMTPD.
  3. During the installation, you'll be asked to choose the installation directory. Choose a location like C:\OpenSMTPD.

Step 2: Configure OpenSMTPD

  1. Open the OpenSMTPD configuration file in a text editor: C:\OpenSMTPD\etc\opensmtpd.conf
  2. Add the following lines to the end of the file:
    listen on lo 0.0.0.0 port 25
    accept from any for any
    milter-local

    This configuration tells OpenSMTPD to listen on all available network interfaces (including localhost) on port 25, accept mail from any sender, and use the local milter (a mail filtering system).

Step 3: Install PostfixAdmin

  1. Download the PostfixAdmin installer from the official website: https://sourceforge.net/projects/postfixadmin/
  2. Run the installer and follow the prompts to install PostfixAdmin.
  3. During the installation, you'll be asked to choose the installation directory. Choose a location like C:\PostfixAdmin.

Step 4: Configure PostfixAdmin

  1. Open the PostfixAdmin configuration file in a text editor: C:\PostfixAdmin\config.inc.php
  2. Update the following settings:
    $CONF['configured'] = true;
    $CONF['smtp_server'] = 'localhost';
    $CONF['smtp_port'] = 25;
    $CONF['domain_name'] = 'example.local';

    This configuration tells PostfixAdmin to use the local OpenSMTPD server, port 25, and the domain name example.local.

Step 5: Start OpenSMTPD and PostfixAdmin

  1. Start the OpenSMTPD service:
    • Open the Services console (Press Win + R, type services.msc, and press Enter).
    • Find the OpenSMTPD service, right-click it, and select "Start".
  2. Start the PostfixAdmin service:
    • Open the Services console (Press Win + R, type services.msc, and press Enter).
    • Find the PostfixAdmin service, right-click it, and select "Start".

Step 6: Test your mail server

  1. Open a command prompt or PowerShell as an administrator.

  2. Use the telnet command to test the mail server:

    telnet localhost 25

    You should see a response from the mail server.

  3. Use a mail client like Thunderbird or Outlook to send an email to a local email address (e.g., [email protected]).

That's it! You now have a basic mail server running on localhost on your Windows system.