In this episode, we're tackling how to send an order confirmation email when someone places an order in our app. Since we touched on emails earlier, now we're building out the one that confirms an order was made.
We'll start by generating a new Markdown email using the php artisan make:mail
command—just like we did before for other order updates. We set up the new email layout and wire it up to accept the order details. Setting the subject to something clear like "Your order has been placed," we prep the template so we can easily add in extra order info later if we want.
Next, we hook up the email logic in the checkout process. Because our orders don't always have a user attached, the email goes to whatever address was entered with the order, authenticated or not. We then test it all out: place a new order, open up MailHog, and check that the confirmation really gets sent.
By the end of the video, you’ll have the order confirmation email going out automatically, and you can customize the content as you see fit!