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:
- Windows 10 or later (64-bit)
- Administrator privileges
- A static IP address (e.g., 127.0.0.1 for localhost)
- A domain name (e.g., example.local)
Step 1: Install OpenSMTPD
- Download the OpenSMTPD installer from the official website: https://opensmtpd.org/
- Run the installer and follow the prompts to install OpenSMTPD.
- During the installation, you'll be asked to choose the installation directory. Choose a location like
C:\OpenSMTPD
.
Step 2: Configure OpenSMTPD
- Open the OpenSMTPD configuration file in a text editor:
C:\OpenSMTPD\etc\opensmtpd.conf
- 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
- Download the PostfixAdmin installer from the official website: https://sourceforge.net/projects/postfixadmin/
- Run the installer and follow the prompts to install PostfixAdmin.
- During the installation, you'll be asked to choose the installation directory. Choose a location like
C:\PostfixAdmin
.
Step 4: Configure PostfixAdmin
- Open the PostfixAdmin configuration file in a text editor:
C:\PostfixAdmin\config.inc.php
- 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
- Start the OpenSMTPD service:
- Open the Services console (Press
Win + R
, typeservices.msc
, and press Enter). - Find the OpenSMTPD service, right-click it, and select "Start".
- Open the Services console (Press
- Start the PostfixAdmin service:
- Open the Services console (Press
Win + R
, typeservices.msc
, and press Enter). - Find the PostfixAdmin service, right-click it, and select "Start".
- Open the Services console (Press
Step 6: Test your mail server
-
Open a command prompt or PowerShell as an administrator.
-
Use the
telnet
command to test the mail server:telnet localhost 25
You should see a response from the mail server.
-
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.