Homestead is a package you can use in your Laravel development to create a local development environment for your application with all the services installed you can use to improve the workflow of your application.
Homestead will then create a new virtual machine with the following software installed.
The problem comes when you do integration testing on your application with “real world” data you might come into the situation where an dev email can be sent to a real user. There are a few ways you can get around this one of the most common old fashion ways of doing this was inside the sending email class you check the environment and if local change the email to address to the site admin email address, making sure all outgoing email goes to the site admin in local.
This solution isn’t ideal, if you have multiple developers they will all need access to this mailbox, if you use an smtp service these dev email could be costing your company money. Mailhog is the solution for your development emails, it will watch for outgoing traffic using SMTP and collect the email and store it locally instead of sending the email. The email it’s collected can be viewed in the mailhog UI so you can see all dev emails in a nice client UI. Once installed all you have to do is go to the IP of the machine on port
If you use Homestead for your Laravel development you already have mailhog installed and can use it straight away, all you have to do is change your mail environment settings in your
.env to the following.
Now when you send emails from Laravel you’ll be able to see it straight away in mailhog.
To learn more about mailhog and keep up to date with any updates you can follow the package on github.
Originally published at https://paulund.co.uk.