How do I test sending emails on localhost using SMTP?

  • Page Owner: Not Set
  • Last Reviewed: 2020-01-21

I have a new feature that sends out an email to the user and I'd like to test this out. What is a good way to set up a local SMTP server to send these emails and check them out?


Answer

Most of the devs at Blend use an application called smpt4dev. It sets up a dummy server that you can point to for handling email sent via SMPT. This server will receive the email and you can inspect it or delete it, but it does not actually sent the email off to the destination mailbox.

The newest version of smpt4dev will run through a browser interface (which I use) but you can still find the older application that other devs here utilize. Once you set up smpt4dev, just change the web.config of the project to point your mail settings to look like the following and you should be set up to start sending test emails for smpt4dev to catch.

<mailSettings>
  <smtp from="{email Address you're sending from}">
    <network host="localhost" port="25"/>
  </smtp>
</mailSettings>

Comments

  • As a side note, you probably should always have your local instance sending email to localhost, even if you're not using smtp4dev, so you're not accidentally bombarding clients with email through their production smtp server.