Setup a new project using Laravel Sail (macOS)#1 - 02:33
Executing commands inside your application containers#2 - 02:20
Creating a database client connection#3 - 01:30
Testing emails with Mailhog#4 - 02:35
Changing the php version in Laravel Sail#5 - 01:29
Run Sail and Valet in parallel#6 - 01:39
Customizing Laravel Sail#7 - 01:25
Setup Laravel Sail for an existing Laravel application#8 - 00:49
Testing emails with Mailhog
[00:00] If you've ever tested emails in Laravel, there's a good chance you might have used something like mailtrap.io. Laravel Sail ships with a similar tool called Mailhog. If you open your environment file and scroll down to the mail configuration, you'll see that the mail host is set to Mailhog.
[00:23] If you also open
docker-compose.yml and look for Mailhog, you'lll see that there are two ports configured. The first one is the smtp port, and the second one points to the Mailhog dashboard. We can access that dashboard by opening the browser and going to
localhost:8025. And here it is.
[00:53] Let's create an email, send it, and see if this thing works. Open your terminal and type in
sail artisan make:mail HelloMail --markdown=emails.hello, the name of the mail, and to make it markdown based, we can do
--markdown=emails.hello and this will create an email directory with a
[01:23] Let's open the
hello view; resources, views, emails, hello, and let's just say "Hello, nice to meet you!" and save. Now to send it, let's open our web routes, and here inside the root url we can do
Mail::to('email@example.com')->send(new HelloMail()) - and let's make sure we import the mail facade.
[02:00] Now to test it, let's visit the root url. So I'll go to localhost, and we receive this error becase we forgot to set a sender address. To do that, go to your environment file, and here mail from address, set your e-mail.
[01:19] Now let's give it another go. And if we check Mailhog, here is the email. We can click it, view the html, the plai text, source, mime type, etc.