WEBVTT

00:03.790 --> 00:04.210
Hey there.

00:04.210 --> 00:05.380
Everyone had a share.

00:05.380 --> 00:06.970
And welcome to another video.

00:07.000 --> 00:10.050
The next hour that we are going to work on is Forgot Password.

00:10.060 --> 00:11.890
Now Forgot Root Forgot Password.

00:11.890 --> 00:13.510
Root has to component itself.

00:13.510 --> 00:18.160
You might have seen already in majority of the websites that first you actually go on to the forgot

00:18.160 --> 00:19.060
password page.

00:19.060 --> 00:22.730
There you simply enter your email and say, Hey, I forgot my password.

00:22.750 --> 00:25.840
Now once you click on that, it obviously goes into the database.

00:25.840 --> 00:30.910
Look for the user, whether this user exists or not, and then sends you instruction over the email

00:30.910 --> 00:31.540
itself.

00:31.540 --> 00:37.150
And then you simply click on the button and allows you to ask the change the password or set the password

00:37.150 --> 00:37.930
in that case.

00:37.930 --> 00:42.910
So for this, obviously we are going to need to shoot an email and we already got the node mailer and

00:42.910 --> 00:46.720
shooting the email is really well the easiest thing of all in the entire world.

00:46.720 --> 00:49.450
And this example itself is just more than enough.

00:49.540 --> 00:54.460
Let's go back up here and create a utility for that, because obviously this is a mail function and

00:54.460 --> 00:57.850
maybe a lot of people and a lot of places it might be useful.

00:57.850 --> 01:03.310
So let's go ahead and create a new email and we are going to call this one as simply email helper because

01:03.310 --> 01:05.410
it's going to help us to shoot email.

01:05.650 --> 01:07.390
Did I wrote it correctly?

01:08.830 --> 01:09.620
Yep.

01:09.940 --> 01:11.350
Looks like really short one.

01:11.350 --> 01:13.990
They're very difficult to see.

01:14.020 --> 01:14.680
Come on.

01:14.860 --> 01:15.640
Email.

01:15.920 --> 01:18.340
Helper dogs, of course.

01:18.950 --> 01:19.210
Okay.

01:19.240 --> 01:19.710
Yeah.

01:19.720 --> 01:20.470
Looks good.

01:21.670 --> 01:22.930
So how this is going to work?

01:22.930 --> 01:24.340
We are going to just borrow the code.

01:24.340 --> 01:24.910
Absolutely.

01:24.910 --> 01:29.020
From here, we have already installed the node mailer, so first line is to bring the node mailer.

01:29.050 --> 01:30.920
Let's go ahead and bring the node mailer.

01:30.940 --> 01:32.950
Now we're going to go ahead and export a method.

01:32.950 --> 01:38.140
So let's go ahead and call this one as simply what should we call this one as male helper.

01:39.290 --> 01:41.690
Yeah, that sounds a really nice name.

01:41.690 --> 01:47.120
And obviously this is going to be a simple async method and this one is going to go like this.

01:47.630 --> 01:48.800
And there we go.

01:48.830 --> 01:53.120
Now, once we are done with that, obviously the most important thing to is to export this one.

01:53.120 --> 02:00.200
So we're going to go ahead and say module dot exports and we're going to be exporting this mail helper.

02:00.680 --> 02:00.860
Okay.

02:01.040 --> 02:03.890
So once we are done with this, let's go ahead and work on with that.

02:03.900 --> 02:08.120
Now what we're going to do is further on the road is again copy more stuff.

02:08.120 --> 02:10.340
So we don't need to create any test account and all of that.

02:10.340 --> 02:12.680
We will be directly working on this transporter.

02:12.680 --> 02:17.600
So let's go ahead and first, in fact, let's bring all of this and then we're going to figure out how

02:17.600 --> 02:18.650
to modify it.

02:18.650 --> 02:20.230
So let's go ahead and bring this up.

02:20.240 --> 02:21.950
A lot of information is coming in.

02:22.370 --> 02:26.990
So the first step is let's go ahead and change this one to cost because we won't be changing it.

02:26.990 --> 02:28.070
The transporter?

02:28.100 --> 02:30.800
No, the mailer will create a transport for us.

02:30.830 --> 02:32.660
It requires a host port.

02:32.810 --> 02:34.460
We want to be using secure and things.

02:34.460 --> 02:40.340
So let's go ahead and remove this part and then we need auth, which requires user and password of the

02:40.340 --> 02:41.180
email itself.

02:41.180 --> 02:43.250
I will walk you through that in a second.

02:43.820 --> 02:46.580
So these are all the options that we are going to grab.

02:46.670 --> 02:53.150
And then it says that, hey, I will be sending an info and it will evade the transfer.

02:53.180 --> 02:59.000
Now again, we don't really want to hold this into available because we won't be using it once the email

02:59.000 --> 02:59.420
is sent.

02:59.420 --> 03:00.050
That's aid.

03:00.050 --> 03:00.950
That's all what we want.

03:00.950 --> 03:06.350
So I'm going to go ahead and remove this one and it simply says, Hey, transporter, don't send mail.

03:06.350 --> 03:07.130
And that's it.

03:07.160 --> 03:10.730
Now, I really don't want this integrity of the message up here.

03:10.730 --> 03:16.190
I would like to cut this out and would like to store that into a into a separate object.

03:16.190 --> 03:18.560
So let's go ahead and call this one as simply message.

03:18.560 --> 03:21.680
And that one is going to be just exactly what we copied it here.

03:22.040 --> 03:23.450
Now, it has a lot of options.

03:23.450 --> 03:27.020
There is a from to subject, text and HTML as well.

03:27.410 --> 03:32.810
We're going to assume that this all from two and all of that are coming from the options so somebody

03:32.810 --> 03:36.650
or anybody who is using this will provide us these options.

03:36.650 --> 03:37.580
So there we go.

03:37.580 --> 03:40.910
And feel free to call the data option whatever you like to have this one.

03:41.120 --> 03:41.630
Okay.

03:42.140 --> 03:44.990
So to email is obviously going to come up from this one.

03:44.990 --> 03:48.200
So options, so let's go ahead and work on with that.

03:48.200 --> 03:50.930
So we're going to say option dot email.

03:50.930 --> 03:53.090
So send me the two email.

03:53.120 --> 03:57.260
You can call it to email as well in case that sounds a little bit more sensible to you.

03:57.260 --> 04:03.020
But again, totally under you now the subject we can actually hard code the subject but let's make this

04:03.020 --> 04:05.300
helper a little bit more flexible.

04:05.300 --> 04:10.820
So we're going to say this one as option dot subject and then the text message.

04:10.820 --> 04:17.030
So this one is going to be save as option DOT message.

04:18.010 --> 04:23.120
And inside this one, also what we're going to do is rather inside, instead of wrapping it into a B

04:23.140 --> 04:29.650
tag, we're going to wrap it into a tag because as of our priority need, what we need to do is send

04:29.650 --> 04:31.420
up a link that is clickable.

04:31.420 --> 04:33.400
So we're going to go ahead and wrap this up.

04:33.400 --> 04:38.170
So the entirety of the link is actually clickable and we have to send the ref as well.

04:38.500 --> 04:41.500
So we are not going to send any HTML.

04:41.500 --> 04:45.730
I'm pretty sure later on we can configure that, but right now I'm going to go ahead and just remove

04:45.730 --> 04:46.660
this body part.

04:46.660 --> 04:50.410
We'll work on the copy pasting as of now, but later on we can figure out this one.

04:50.650 --> 04:51.880
So that is it.

04:51.880 --> 04:53.050
That's all what we need.

04:53.050 --> 04:55.150
But there is a little bit more to it.

04:55.150 --> 04:57.460
We still don't have these SMTP details.

04:57.460 --> 05:00.040
What is the host port auth and all of that.

05:00.040 --> 05:03.190
So for this, I will work on to another service.

05:04.090 --> 05:05.710
Let's go ahead and Google on that.

05:05.710 --> 05:12.760
This is really one of the industry standard service mail trap and you'll find see dozens of industries

05:12.760 --> 05:13.210
using it.

05:13.210 --> 05:15.460
This is like the industry de facto of using the thing.

05:15.460 --> 05:18.070
Just like postman is there to test out all the emails.

05:18.070 --> 05:18.850
There is mail travel.

05:19.150 --> 05:19.900
Oh really.

05:19.900 --> 05:22.870
One of the most amazing service that you can work on with that.

05:22.870 --> 05:26.320
So I hope you can see that they works with almost every language.

05:26.320 --> 05:31.120
If you'll check out the company details who is using them, you'll be pleasantly surprised that from

05:31.120 --> 05:36.490
Adobe to Atlassian to pretty much everybody, every big name uses them, whether they mention it or

05:36.490 --> 05:38.470
not, go ahead and create an account.

05:38.470 --> 05:40.630
They are pretty generous with their services.

05:40.630 --> 05:42.400
So there is a free service as well.

05:42.430 --> 05:45.340
Feel free to use as much as you like on the free one.

05:45.340 --> 05:48.580
They have a pretty generous plan, a login into this one.

05:48.580 --> 05:50.920
So I might be having an account.

05:50.920 --> 05:52.660
I guess I have a account from Google.

05:53.440 --> 05:58.660
So yes, I have a Google account on this one and all I got to do is simply work on with this one.

05:58.660 --> 06:04.930
So what I'm going to do is I need to grab all of the details from where I can grab this one.

06:05.020 --> 06:07.120
Let me quickly go ahead and see that.

06:07.120 --> 06:11.770
Yeah, this is my inbox and let's go ahead and see SMTP settings.

06:11.770 --> 06:14.200
So again, these are integrations being sent.

06:14.200 --> 06:16.510
I am interested into the node here.

06:16.510 --> 06:19.120
So Node Mailer is pleasantly mentioned up here.

06:19.120 --> 06:23.260
So these are all the details that I can have so I can definitely go ahead and replace.

06:23.260 --> 06:28.420
If you noticed, this is entirely a code is given to us, not just the details.

06:28.420 --> 06:33.220
So we have got SMTP, host, port user and password.

06:33.220 --> 06:34.210
All of them are there.

06:34.690 --> 06:39.670
Now what we're going to do is for host, port user and password, we are going to go ahead and store

06:39.700 --> 06:45.970
them into our favorite place process E and v, so E and V file and let's go ahead and add the mail details.

06:45.970 --> 06:51.910
So we're going to go ahead and call this one as SMTP, a really short for simple mail transfer protocol.

06:51.910 --> 06:56.200
So we're going to go ahead and let me see what else we are having up here.

06:56.320 --> 07:01.990
In fact, it would not be wrong if I just go ahead and copy this for a minute and paste it up here at

07:01.990 --> 07:04.150
the top so that I can at least right.

07:04.150 --> 07:04.660
That.

07:04.660 --> 07:15.820
So SMTP underscore host then we have got SMTP underscore port and then we're going to have an SMTP user

07:15.820 --> 07:19.420
and then we are going to have an SMTP pass.

07:19.420 --> 07:19.900
There we go.

07:19.900 --> 07:21.490
So all the details are up here.

07:21.640 --> 07:28.270
All I need to do is put an equal sign and then put up all the details up here so I can go ahead and

07:28.270 --> 07:29.140
put like this.

07:29.140 --> 07:30.040
And there we go.

07:30.580 --> 07:31.990
Okay, let's go ahead and fill this up.

07:31.990 --> 07:33.610
So this needs to go.

07:34.090 --> 07:37.390
Cut this out, paste that up here.

07:37.690 --> 07:38.050
Oops.

07:38.050 --> 07:38.740
My bad.

07:40.120 --> 07:43.300
So cut this out and paste it up here.

07:43.750 --> 07:48.520
This is the port so we can go ahead and cut this out and paste it up here.

07:48.700 --> 07:53.860
This is the user again, in case you are signing up for some other services like eight of Lewis send

07:53.860 --> 07:58.810
in blue or whatever favorite is yours so you can go ahead and just change these details.

07:58.810 --> 08:02.470
And Node Mailer will absolutely work fine in those cases as well.

08:02.830 --> 08:03.100
Okay.

08:03.100 --> 08:05.200
So now there is no need of this one.

08:05.200 --> 08:05.860
There we go.

08:06.520 --> 08:09.880
So now all of our details from the mail trap is here.

08:09.880 --> 08:15.550
All we got to do is simply just replace this one into our mail helper, email helper.

08:15.970 --> 08:17.260
Let's go ahead and change this one.

08:17.260 --> 08:25.900
So this one will be coming up from process dot E and V dot SM SMTP underscore.

08:26.680 --> 08:30.850
Yeah, better to copy that then worry about later on.

08:31.150 --> 08:42.490
So SMTP host and I can actually go ahead and copy this and this one will change to SMTP port again.

08:42.490 --> 08:45.580
There might be some typos eventually that we need to fix up.

08:45.940 --> 08:48.640
And this one is user.

08:50.380 --> 08:57.460
So SMTP user and this one needs to go away and this one is a SMTP password.

08:57.550 --> 09:00.700
So process dot e and v smtp pass.

09:01.420 --> 09:07.570
So all the details are now being controlled by my E and V file, which is using a service known as mail

09:07.570 --> 09:08.110
trap.

09:08.110 --> 09:11.200
And I will be able to see all of the e mails up here.

09:11.200 --> 09:14.050
Again, these are good crafters are some another project.

09:14.290 --> 09:15.970
We don't need to worry too much on that.

09:15.970 --> 09:18.190
We will be getting our again notice here.

09:18.190 --> 09:20.170
Email addresses and all these things are up here.

09:20.170 --> 09:22.330
All you got to do is monitor your inbox.

09:22.630 --> 09:25.690
Right now there are four messages in my inbox.

09:25.900 --> 09:30.190
Hopefully, as we will be sending more, there will be more messages in my inbox.

09:30.190 --> 09:30.910
So there we go.

09:30.910 --> 09:33.700
I can close this one here and email helper.

09:34.120 --> 09:37.830
Okay, one one thing I forgot is pass on this message up here.

09:37.840 --> 09:39.160
Almost forgot that.

09:39.400 --> 09:40.330
So there we go.

09:40.330 --> 09:42.130
Now this message is being used here.

09:42.130 --> 09:46.270
And as soon as the say is transferred or send email, it is going to send me an email.

09:46.600 --> 09:50.380
Some people have seen again, this is a Fred faux fu example.

09:50.680 --> 09:52.150
We need to change this one again.

09:52.150 --> 09:54.070
Let's go ahead and change this one also.

09:54.490 --> 09:56.980
So we're going to go ahead and change this one here.

09:57.250 --> 10:01.690
So this one is usually hardcoded from whatever the website you are using.

10:01.690 --> 10:04.000
So they give you your own emails as well.

10:04.000 --> 10:06.190
So we're going to go ahead and change this one.

10:06.190 --> 10:08.530
So let's go ahead and kind of a hard code, this one.

10:08.530 --> 10:10.990
So hit the ish at the rate ae dev.

10:11.770 --> 10:13.510
Again, these are from emails.

10:13.510 --> 10:18.880
So usually you will also get an account onto a W, s or whatever the website you are using and all these

10:18.880 --> 10:20.620
emails actually generate from your address.

10:20.620 --> 10:24.880
So usually this value is hardcoded or can be controlled by process tab.

10:24.940 --> 10:26.380
So that's it for this one.

10:26.380 --> 10:28.330
Let's go ahead and catch up in the next video.
