Introducing Markdown Mail 0:00Welcome back. So in the last episode, we learned how to send email. And we learned it's very, very simple to set up. We generate a email class, we specify a view, and then we also learned that any public properties you have defined will be available within that view. But now, what if we want some formatting out of the box? Especially for developers, this kind of sucks. But luckily, Laravel can help with this. Let's generate a new email. We'll say make mail, and we'll say welcome again, our second try. Generating Markdown Mailable 0:25Let's generate a new email. We'll say make mail, and we'll say welcome again, our second try. But this time, I'm going to add the markdown flag and specify a view path. So we'll do emails.welcome again. Okay, so let's see what changes simply by adding that markdown flag. If we take a look at the class, it looks similar, but now, rather than calling view, it referenced a markdown method, and it populates that. But next, if we go to resources, views, emails, you'll see that it also generated this file for us. Using Mail Components 0:51But next, if we go to resources, views, emails, you'll see that it also generated this file for us. And it might look a little confusing, because we haven't actually yet talked about components when it comes to Blade. We'll get there soon. But in general, think of these as little components that you can hook into. So in our case, we're going to prepare a message, and this will be the body of the message. But we also want a little button component. So we reference that, and we want the text to be this.But we also want a little button component. So we reference that, and we want the text to be this. There's even other ones, like panels. So I could say I want a panel button, and we'll say lorem ipsum dolor. The cool thing about this is it allows us to write and markdown, 1, 2, 3, any kind of markdown you want. But it also gives us inline styling and layout right out of the box. So let's try this out. We'll do it directly in the command line. Sending and Viewing Email 1:38So let's try this out. We'll do it directly in the command line. So I will say mail. We're going to send this to some kind of user. So we will find the first one. And we will send a new app mail. Welcome, again, is what we called it. And that does require the user. Okay, that was fired off. So I can switch over to Chrome, and here's the email.Okay, that was fired off. So I can switch over to Chrome, and here's the email. But this time, you'll see that we have some styling out of the box. Let's open this in a new tab to see it. So we get a little header that has the application name. We have all of the markdown that was converted. And further, you can see that all of the styling is inlined, as you can see right here. Laravel does that entirely for you. It's really cool.Laravel does that entirely for you. It's really cool. And then, of course, we have a button, our panel, and then our footer. Okay, so let's take another look at this. We have our message, which is all of this, and then we have our markdown. And then we wanted a button, so we referenced the button component, and that will generate this for us. So we could set the URL to something like laracast.com, and then start browsing. And we'll say, thanks so much for registering.and then start browsing. And we'll say, thanks so much for registering. Next, this panel section, yeah, that will basically give you a little box here. Some inspirational quote to go here. Okay, finally, config app slash name. So right now, we can see that's set to Laravel. Let's override that. We'll go into config app, and you'll see right now it's defaulted to Laravel. We're going to update that to Laracast. And by the way, that's also the field that's going to be usedWe're going to update that to Laracast. And by the way, that's also the field that's going to be used for the header at the top. Okay, so let's close this out and give it another shot. This time, it'll be a little bit different. Take a look, and let's open in a new tab. There we go. Thanks so much for registering. We can start browsing, and we're all set to go here. Really cool, right? Pretty fancy. So yeah, in general, you'll have a panel component, a button component. Publishing Mail Templates 3:27Really cool, right? Pretty fancy. So yeah, in general, you'll have a panel component, a button component. There's even a table component, where if you want to create a table and markdown, you could reference that, mail table. Very, very useful, maybe for a purchase overview or something like that. Now, this will definitely get you started, but it might be the case that you want to customize these components here. So what you can do is publish these. We can use the vendor publish command. So we're basically taking any vendor files and publishing them to our project root.We can use the vendor publish command. So we're basically taking any vendor files and publishing them to our project root. And we do this so that we can modify the files. But specifically, I don't want to publish everything. I just want to publish the one that has a tag of Laravel mail. And you can see this in the documentation. All right, so now you'll see it copied the views from the composer package that was installed into our vendor mail folder. Let's take a look. Resources, Views, Vendor, Mail.Let's take a look. Resources, Views, Vendor, Mail. And there we go. We have all of the files for the HTML and markdown. So in terms of styling, yeah, we can override this however we want to. And now let's update anything we want. For example, the link in the header should be a color of red just to be specific. Okay, but now if we were to try this, it's not going to take effect just yet. We need to update our theme. So we will visit our config, mail file, and let's look for theme. Applying Custom Theme 4:44We need to update our theme. So we will visit our config, mail file, and let's look for theme. And there we go. So here's our markdown settings. The default theme is not default anymore. It is the Laracast file that we created. All right, so let's try another message. Switch back to Chrome, and here it is. And sure enough, we're using our new custom theme. And, of course, you can modify that and style it however you want.And sure enough, we're using our new custom theme. And, of course, you can modify that and style it however you want. All right, this should get you started.