Loading
Current section: Email 6 exercises
lesson

Intro to Email

Loading lesson

Transcript

00:00 To verify our users, we're going to need to send an email address. There's all this conversation about validating email addresses, but the only real way to validate an email address is to send an email and have the user prove to you that they have access to that email by verifying that. We're not going to get into verification in this exercise.

00:18 This exercise is all about sending the email, but we don't want to send a real email during development because then we have the whole email flow that just disrupts our development. In addition, it will cost us money to run tests because we'll be integrating with that email process, and that's not fun. So instead, we're going to mock out the email sending

00:38 so that during development and testing, we can have that email mocked out. And then in production, we can actually send the email. But how do we do that? Well, unfortunately, a third-party service is a must for this. Unless you are building an email service, you should not be sending your own email.

00:56 And it's actually really unfortunate because I really value running your own services and just owning your own destiny with everything. But unfortunately, there's this article titled, or with a part of the title, the oligopoly has won. And it's just, it is so depressing actually to read.

01:17 So feel free to read the article. Basically, the number of email hosting providers, like the Gmails and Hotmails of the world, all of these different email hosting providers have set up so much spam protection

01:35 that it is just so difficult to get a good reputation in sending email. And so for that reason, you need to use a service that is just 100% dedicated to giving you the best deliverability possible.

01:51 If you don't do this, your deliverability will likely suffer, which is such a shame. So the question is, what email service do you use? I've evaluated many of them. And my favorite is Resend. So you can take a look at Resend. It's a great service. And we're going to be using the Resend REST API to send emails.

02:12 In addition, the Resend team also has built a package called React Email that allows you to create your emails out of React components, which is just phenomenal. It's awesome. And so you import the React Email components,

02:32 and then you can say, here's the contents of my email. Then you can render it with their special render async method that they offer you, and get the HTML and the plain text out of that, and then use that to send email. We're actually not going to get into this specifically,

02:51 because it's really just like, that's it. You do this and write React code. And so there's not a lot that we're going to be talking about. As far as authoring the emails, I'm more interested in teaching you how to send the emails and how to mock things so that you don't actually end up sending real emails during development.

03:10 In addition, we're going to talk about how to pass data from one route to another so that you can have one route that's responsible for sending the email. And then when the user comes back after checking their email and stuff, you still have the data that they submitted. And so that way, they can continue on with their flow. So we're going to be doing some of that too. There's a lot of really good stuff in here.

03:30 So let's jump in.