A simple local Windows mail server for testing PHP scripts

Over time I used all sorts of solutions to test the email sending functions of my PHP scripts during development on my local Windows machine. They all had some pros and many cons and kept me searching for a better way of testing.

For quite some time my preferred solution was to point my mailserver settings in php.ini to some external email server. But I had to make sure that the outgoing emails were not send to the real-life recipient addresses (jamming my customers email inboxes during my development). So this required script changes to make sure the scripts would recognize the local development system and send emails only to special testing addresses while on that system.

Meanwhile I found a better solution that does not require any changes to the scripts that I am testing. I now use a very small and simple freeware email server running on my Windows development machine. In my php.ini I set up localhost as the standard SMTP server to send emails to. The effect is that all emails sent from my local PHP scripts are transmitted to my little local email server, from where they can be polled locally with any email client program. Relaying is switched off in this server, so the emails can never reach the outside world.

Here are some step by step instructions to reproduce my solution:

PHP setup

Set the PHP SMTP server address to localhost, so PHP does not send out of your local environment. I also prefer to set the SMTP port to something other than 25 to hide the local SMTP port from any outside access:

SMTP = localhost
smtp_port = 10025

Mail server

I use “ArGoSoft Mail Server .NET Freeware”. Although this freeware version is quite limited in its functionality, it is ideal for our purposes.

Go get it from ArGoSoft’s website, install and start it.
[UPDATE 20111123] Unfortunately the software is not available on the ArGoSoft website anymore. But you can easily find it on the web (search for “MailServerFreeSetup.msi”). Here is a working source:
Download, install and start it.
[UPDATE 20121114] After multiple users reported viruses in the download file, I re-visited and found that the above source had tampered with the original file and started to spread an infected version!!! Please use this source instead (thanks to mrbellek for the hint!). And please make sure that the file is of type .msi (not .exe) and that the file size is below 700kb. Please be careful!

Download, install and start it.

[UPDATE 20120813] When the server is up and running you can open the mail server console window from the Windows tray at the right (or bottom) end of the task bar. Look out for this icon: . As the mail server is a simple Windows service, the software does not appear in the list of installed programs under the Windows Start button.

From the console window choose the Options tool and set the SMTP port to the same value that you used in php.ini – you probably want to do the same with the POP3 port:

SMTP Port: 10025
POP3 Port: 10110

Activate “Load Server at Windows Startup” and “Start Automatically when Launched”. Without the second option the mailserver software will be run but the process listening on the mail port will not be started. Leave all other input fields and checkboxes in the Options dialog empty and unchecked. In particular do not allow Relaying, and do not activate SMTP Authentication (if you don’t want to make your life more complicated than necessary).

From the console window choose the “Users and Domains” tool and add all domains and all users that you expect your PHP scripts to send emails to. The ArGoSoft Freeware Mailserver does not distinguish between several domains that you define, so for each user you create all domains will be active:

Domains:  digilog.de, digilog.info, digilog.biz
Users:    myself

This setup will accept incoming emails to…

myself@digilog.de, myself@digilog.info, myself@digilog.biz

…and all emails will go into the same email account that can be polled by accessing localhost with login data myself and the password that you defined for that user.

Now to poll your emails in your favorite email client, you simply set up a new email account retrieving mail from localhost with the above user data and the special ports that we defined above.

The nice thing about this solution is that the limitations of the freeware version actually turn into an advantage for us. Whatever email addresses your scripts will try to send to, simply set them up in ArGoSoft’s domain and user section and any emails will be intercepted and collected in just a few central accounts. When you later push your scripts to the live server, they will work without any changes and will really send out their emails into the world.

Dieser Beitrag wurde unter Configuration, Email, PHP, Windows abgelegt und mit , , verschlagwortet. Setze ein Lesezeichen auf den Permalink.

22 Antworten auf A simple local Windows mail server for testing PHP scripts

  1. Lee Firth sagt:

    I’ve been struggling with email testing for some time, wish I’d found your solution sooner. Great tutorial.

  2. Arturo Ramirez sagt:

    Good day,

    I need to develop a PHP script to send an e-mail using information filled in a web page like this one I am writing now (just name, e-mail, subject and message).
    As in this case, when I press “Post Comment” button, “wp-comment-post.php” is executed. I want to have a script like this one. Is it possible for you to help me?

    Arturo Ramirez

    • Jörg Wagner sagt:

      Hello Arturo,
      your request is beyond the scope of this posting. But there are many free solutions for what you are trying to do.
      Have a Google search for “formmail”. You will find a script by Matt Wright that is probably the number one in terms of world-wide usage. It is written in Perl. And there are many other solutions out there, written in PHP or any other language that you desire.
      Cheers, Jörg.

  3. Pingback: testing php mail() on your localhost - Webmaster Forum

  4. Daraper sagt:

    The software does not work on vista, this is the most easy to used and it worked good for me before, but… since I’m on vista… You can forget about it!! The Argo developer seems not to be able to jump up to Vista so it won’t even install

    • Jörg Wagner sagt:

      Hi Daraper,
      I currently have version (dated 2011-02-26) running on Windows 7 64bit without any problems. Frankly I don’t remember whether I installed it with normal or elevated rights – but this should be an easy test.
      The major problem I found is that the free version is not available on the Argosoft website anymore. But you can easily find it on the web (search for “MailServerFreeSetup.msi”). Here is a working source: http://argosoft-mail-server.soft-ware.net
      I have updated the posting accordingly.
      Cheers, Jörg.

  5. jan sagt:

    that Argosoft software installs some kind of crap on my computer and no trace of any mail server.

    • Jörg Wagner sagt:

      The mailserver is a service and does NOT appear under the Start button in the list of installed programs. The management console appears in the Windows tray. I have added this information to the article. Beside that and to my full knowledge the software does not install any “crap” on your system. See my edit in the article for a new clean source of the file!

  6. Tim Dawson sagt:

    I got two unrequired toolbars added to Firefox during this process. I’m not sure if it was from the link Jorg provided, or (more probably) something I searched for under ‘MailServerFreeSetup.msi’. Either way it was irritating, and one always wonders what might have got installed that wasn’t so obvious. It reminded me to make a copy of my Firefox profile on this new computer.

    I have been able to install the program from Jorg’s link, and I’m working on customising it. (Win 7 x64).

    • Jörg Wagner sagt:

      Hi Tim,
      the Argosoft installer does not install such things and the download website that I linked in the article is was very clean and does did not try to make you click the wrong download button (as many other freeware download sites do). You must have catched that stuff somewhere else. See my edit in the article for a new clean source of the file!
      Cheers, Jörg.

      • Tim Dawson sagt:

        Hello Jörg,
        I’m sure that the rogue items didn’t come from Argosoft or the download site. I’m equally sure that they came from visiting some site that Google found when I googled ‘MailServerFreeSetup.msi’. I reported it because Jan seems to have had a similar experience on 13 August.

        On the bright side, I’ve got Argosoft running perfectly. Thank you for the information.

        Is there any way to get all Argosoft users into the same e-mail account so they can all be downloaded using one e-mail client account ? I ask because I have to test several sites, and some send messages back to fixed addresses like ‘webmaster@…’ or ‘bookings@…’. I can set those up as Argosoft users easily enough, but then I have to keep changing the name of the receiving account in Thunderbird to match. Possible but tedious.

        My ISP does somethng like the above, and I can download mail addressed to several appearently different e-mail accounts into one Thunderbird account. However, I realise the ISP is using some heavy-weight program, not a deliberately lite one like Argosoft.
        Best Wishes,

        • Jörg Wagner sagt:

          After multiple similar comments from other users I re-downloaded and found that the source in my original posting now spreads an .exe instead of a (considerably smaller) .msi file. They obviously try to spread added crap. I have edited my article accordingly.

          Concerning your question with multiple email addresses going into one account:
          Yes this is possible, and I have explained that in detail in my article – please re-read. In fact this is one of the most practical things about the Argosoft mailserver (although it would actually be considered a deficiency in most other scenarios).

  7. James sagt:

    it looked like a good solution, but AVG warns for a virus / trojan in the application, plus I don’t trust installers that try to install all kinds of toolbars.
    I’ll keep looking for a more reliable program.

    • Jörg Wagner sagt:

      Yes, you are right. After similar comments from other users I re-downloaded and found that the source in my original posting now provides an .exe instead of a (considerably smaller) .msi file. They obviously tampered with the file and try to spread added crap. I have edited my article accordingly. Thanks for the hint!

  8. russian with vodka and bear sagt:

    I used this in conjunction with sendmail.exe – for windows. Thankx for the tutorial, the server works great.

  9. Simeon Jackson sagt:


    This is just what I needed to be able to do my web development! Thanks so much!

  10. Flor sagt:

    Thanks a bunch! I was struggling my head out trying to configure several mail servers with no success. Your post saved my time!
    Regards from Argentina.

  11. Paul sagt:

    And, what need to coding (e.g. in Apache Commons Mail) using Java for send mail?


  12. Flor sagt:

    I was looking for this smtp server for years… Thanks!

Hinterlasse eine Antwort

Deine E-Mail-Adresse wird nicht veröffentlicht. Erforderliche Felder sind markiert *

Du kannst folgende HTML-Tags benutzen: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>