Hi folks,
I often use Mailhog for testing of emails without needing to send actual email through a service like mailgun, and it seemed worth sharing here.
What’s Mailhog?
Mailhog is an easy to install tool, that acts like an email server, letting you send email to a ‘fake’ inbox, so you can get an idea of what emails look like without needing to send them through the internet.
It’s based on the earlier Mailcatcher, which is where I pilfered this screenshot to give an idea of what these kinds of tools do:
However, being a single go binary, it’s easier to install and use, and you don’t need to know much about python to use it:
Using Mailhog and Ghost for testing emails.
You can use Mailhog to test sending emails, without needing to connect to the internet, if you’re on a train for example, or you’re working on templates, and need to send a few emails as a sanity check, and don’t want to cruft up your inbox:
First install Mailhog. On OS X, it’s brew install mailhog
.
Then update config.development.json
, to replace this:
"mail": {
"transport": "Direct"
}
With this:
"mail": {
"transport": "SMTP",
"options": {
"host": "0.0.0.0",
"port": 1025
}
},
And you should have easy local email testing!
This is also useful if you locked yourself out of your development environment like I just did, and forgot the password you used to get in…
Hope this helps some other soul, or even future me, when I forget and search in six months