Getting emails to work on WordPress running on IIS Express (WebMatrix)

I’m working on a WordPress project locally on my PC, deployed via WebMatrix. I love how easy Microsoft has made the process of trying out web apps with the Web Platform Installer. It’s a great way to get up and running, so that you can concentrate on the process of writing code, rather than setting stuff up.

There is one snag though: IIS Express doesn’t include a SMTP server. So, none of the activation or notification emails ever get to the recipient. You can configure it IIS Ex to use a specific SMTP server if you have one by editing the web.config file WebMatrix created for you on the web app’s folder. You simply add:

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
  ...
  </system.webServer>
    <system.net>
        <mailSettings>
            <smtp>
                <network
                        host="localhost"
                        port="25"
                        userName="username"
                        password="password"/>
            </smtp>
        </mailSettings>
    </system.net>
</configuration>

So, I tried this with couple of free SMTP servers out there (this and this). Neither worked for some reason and I kept getting errors; probably due to GMail rejecting 127.0.0.1 as a sender.

20:03:50 [3] Looking for MX domain of gmail.com
20:03:56 [3] gmail.com Domain resolving error: TimedOut
20:03:56 [3] Retrying DNS resolution

An alternative would be to use a GMail account itself and use GMail’s SMTP server. But, you really cannot configure IIS Express to email through SSL. So, that doesn’t work either. Relaying using hMailServer seemed promising. But, if I wanted to have a fully fledged server running, I might as well have used IIS.

Then again, since I’m only using this WordPress installation for development and testing, I didn’t really need the server to be sending out the emails to the recipients anyway. All I needed was to make sure that the emails were sent; or in the case of activation emails, to get the activation link.

So, here’s what I did:

  • Started miniRelay.
  • Go to Configuraton > Advanced and turn on “Do not return mails” option. Click Ok to close the Configuration window.
  • Let WordPress send out the emails (either by creating a new user, posting a comment, etc). Wait till miniRelay failed again.
  • Go to the miniRelay folder and look in the /queue folder
  • Open the latest *.dat file in a text editor, and you will have the contents of the email that you are looking for.

2 thoughts on “Getting emails to work on WordPress running on IIS Express (WebMatrix)

  1. I installed the WP-Mail-SMTP plugin and was able to send out emails via the same settings as my Thunderbird outgoing email. I am running Windows 7 with a WebMatrix / WordPress installation. I haven't tested the new user, comment post notifications but was successful with using the Contact Form 7 plugin

    Like

    1. Thanks for the info!
      I looked up the plugin and it is mentioned to have SSL/TLS support. So that would work with the GMail SMTP server. So, this definitely is an option.

      Like

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.