ruk·si

📧 Email Testing

Updated at 2019-01-28 09:10

You frequently have to fine-tune how your web app HTML emails work and look. Printing HTML to console or saving emails to files does work in simple cases. However, if you need to do this a lot, it makes more sense to run a simple local SMTP server with browser UI to smoothen out the development loop.

I prefer Mailslurper as it's dead simple.

Install the latest version from Mailslurper releases

mkdir /Applications/mailslurper
cd /Applications/mailslurper
curl -L -O https://github.com/mailslurper/mailslurper/releases/download/1.14.1/mailslurper-1.14.1-osx.zip
unzip mailslurper-1.14.1-osx.zip
rm mailslurper-1.14.1-osx.zip

You can configure Mailslurper by config.json but default are sensible.

vim /Applications/mailslurper/config.json

Worker directory must have the config.json or the server won't start.

cd /Applications/mailslurper
./mailslurper
# ...
# SMTP listener running on localhost:2500
# HTTP admin listener running on localhost:8080
# ...

Now if you navigate to http://localhost:8080/ you will find the email interface.

open http://localhost:8080/

Finally, configure your application to send emails to smtp://localhost:2500.

EMAIL_URL=smtp://localhost:2500
# or however it is configured