Using MailHog via Docker for testing email
source link: https://akrabat.com/using-mailhog-via-docker-for-testing-email/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
I recently needed to modify the emails that a client project sends out. It was set up to send via SMTP and so the easiest way to do this for me was to add a local MailHog instance and point the application at it.
Manually running via Docker
The quickest and easiest way to do this is via Docker.
Manually, we can do:
This will run MailHog with the SMTP port exposed on localhost port 1025 and the web interface on 8025.
Now you can configure the app’s SMTP config and away you go.
Test via telnet
You can test via telnet fairly easily if you have it installed:
Type each line out and press Enter between each one and you’ll see the new email in MailHog’s web interface:
Docker compose
As I already had a Docker Compose setup for this project, I added the following to my docker-compose.yml:
MailHog’s logs are quite chatty, so adding driver: 'none' to the logging section will turn them off if you don’t need them.
That’s it. I used to use Mailcatcher and still do on one project, but MailHog’s Docker container makes it much easier and quicker to set up.
Recommend
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK