Effortless email testing with FakeSMTP

Each web application today sends some emails out. Those could be various information, reports, notifications etc. Sooner or later you will get a task to prepare and send an email. There are different ways how you can code the logic for generating email messages. What can sometimes be a bit cumbersome is testing this logic during development.

There are three major concerns, when it comes to email testing. One is configuring the right SMTP server, which is reachable, can talk with the application and takeover the sent email. Second is making sure that no test email reach real users, because nobody likes to be spammed (one could easily become confused, or even angry). The last one is taking care that your SMTP server does not get blacklisted, which can happen if you send a lot of funny “test 123456” emails out to the internet. Little tools like FakeSMTP could get very handy in resolving those concerns.

About FakeSMTP

FakeSMTP is a free fake SMTP Server with GUI for testing emails in applications easily. Configure your application to use “localhost” as your SMTP server, and all emails will be intercepted and displayed in this software. Find more details on the tool’s website. Despite its name, it is actually a real SMTP server and is seen like that from your application. The “fake” part comes from the fact that it will not forward further any email message it receives.

I’m sure there are many good solutions for email testing out there, but this one I like very much. It is easy to run and straightforward to use. You can open the received email message in your default email client, just as you are opening it directly from your inbox folder. You can also see SMTP protocol communication logs, as well as to read email headers and raw data. Mails are also saved to a local folder. The tool is open source and hence free to use for commercial and non-commercial projects. It is written in JAVA and can run on any OS.

Configuring development environment

In order to run this tool, you will need Java 1.6 or newer installed on your machine, which you most probably already have. Once you download the tool and extract a Jar file. Double click the Jar file to run it (or run: java -jar fakeSMTP.jar). You will see the tool GUI:

Change the listening port if needed (default: 25) and press “Start server” button. Immediately you will have a running SMTP server on your local machine, waiting for new emails to arrive. If the port 25 is taken by some other process, use any free port higher than 1024. E.g. it’s popular to use port 2525 for test SMTP servers.

Configure your application to use localhost as SMTP server and a corresponding SMTP port – and you are ready to go.

Cannot configure localhost as your SMTP server?

Sometimes, in your project, it would not be possible or convenient to change configured SMTP to be localhost. The reason could be that other teams are using the same code base, where the SMTP server configuration is committed. It is not easy just to change it locally and make sure you will not mistakenly commit that change later. Or your enterprise test SMTP server is down but you need to do a quick “last-minute” task which involves some mailing.

Let’s say your configured SMTP server is testsmtp.mycompany.com. Edit your hosts file and add:

127.0.0.1 testsmtp.mycompany.com

After you save the changes, all emails sent to testsmtp.mycompany.com will end up to your local machine – localhost. As a consequence, you will be able to fetch all sent emails using FakeSMTP app. Do not forget to check which SMTP port is used, so you can configure FakeSMTP server properly.

Testing sent emails

When an email is sent from your application you will be able to see it in the Mails list:

Double click on a message and it will be opened by your default mail client, like Outlook, where you can preview it.

All other mentioned features of this nice tiny tool are straightforward and easy to use. See few more screenshots.

Happy mailing!  🙂

2 Comments

  1. Anish John

    You can also use a hosted service like mailnest.io for testing your emails. It also has a free forever plan for limited usage.

    Reply
    1. Drazen

      Thanks for the hint!

      Reply

Leave a Comment

Your email address will not be published. Required fields are marked *

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