WEBVTT

00:00.080 --> 00:03.890
The very first thing we will do is to create a new Gmail account.

00:03.890 --> 00:09.170
So we have a dedicated email address we can use to send emails from the Raspberry Pi.

00:09.260 --> 00:09.440
Okay.

00:09.440 --> 00:12.350
So this email address will be the sender email.

00:12.350 --> 00:15.710
And here maybe you think you could use your personal email address.

00:15.710 --> 00:16.280
That would work.

00:16.310 --> 00:16.550
Yes.

00:16.550 --> 00:19.130
But for security reasons I would recommend not to do that.

00:19.130 --> 00:24.680
And it's also going to be much easier to manage things with a dedicated email address.

00:24.680 --> 00:28.190
So what you can do is open a web browser.

00:28.190 --> 00:30.290
You can do that from the Raspberry Pi directly.

00:30.290 --> 00:32.090
As you can see, that's what I did here.

00:32.120 --> 00:38.150
But you can just open any web browser from any operating system is the same and just go to google.com.

00:38.150 --> 00:41.990
And here you can just click on sign in for example.

00:42.200 --> 00:45.440
And because well, I'm signed out of this account.

00:45.440 --> 00:47.000
But let's say that we create a new account.

00:47.000 --> 00:51.920
So you can here you can click on Create account.

00:51.920 --> 00:56.000
So you should see something like that for example for personal use.

00:56.000 --> 00:59.180
And well for example you can name it Raspberry Pi.

00:59.180 --> 01:01.340
Verify you can choose the name you want here.

01:01.370 --> 01:02.270
Doesn't matter.

01:02.300 --> 01:03.440
Click on next.

01:04.010 --> 01:10.790
Then you make sure that you give a birthdate as well, at least 18 years old.

01:10.940 --> 01:15.770
So for example, whatever, just choose whatever.

01:16.460 --> 01:17.360
Next.

01:18.200 --> 01:19.490
Um, okay.

01:21.260 --> 01:22.070
And here.

01:22.070 --> 01:26.240
Well, if they ask you this question, you're going to create a Gmail address.

01:26.240 --> 01:28.790
That's the one we want to use with the Google account.

01:28.880 --> 01:30.020
Click on next.

01:30.410 --> 01:32.750
So you choose an email address.

01:32.750 --> 01:36.980
So the one I'm going to use for example is course dot Raspberry Pi.

01:37.010 --> 01:38.540
So this one is already taken.

01:38.540 --> 01:40.400
That's the one I created.

01:40.520 --> 01:41.780
Just to give you an inspiration.

01:41.780 --> 01:43.460
If you want to create something similar.

01:43.460 --> 01:45.410
So you create an email address here.

01:45.410 --> 01:46.340
You click on next.

01:46.340 --> 01:48.500
Then they're going to ask you for a password.

01:48.530 --> 01:50.360
You finish the configuration okay.

01:50.390 --> 01:52.730
Maybe you need to validate your account with a phone number.

01:52.730 --> 01:53.720
So you do that.

01:53.900 --> 01:58.040
You may also want to add a recovery email a recovery phone.

01:58.070 --> 02:01.130
Well, you can just configure your account and I'm going to come back to this.

02:01.130 --> 02:05.270
But it's also important that you activate the two step verification.

02:05.270 --> 02:08.900
So if Google asks you do you want to do the two step verification.

02:08.900 --> 02:09.500
You click on.

02:09.530 --> 02:09.770
Yes.

02:09.770 --> 02:13.280
Because that's going to be a mandatory step for the following.

02:13.310 --> 02:13.670
All right.

02:13.670 --> 02:19.040
And once you have created the account you just log in and let's do the configuration so that we can

02:19.070 --> 02:21.110
send emails from the Raspberry Pi.

02:22.250 --> 02:24.440
And once you are connected.

02:24.440 --> 02:27.200
So here I'm back to the Google page.

02:27.200 --> 02:31.190
You can you can just click on your account go to settings.

02:31.310 --> 02:32.990
And there are different ways to do that.

02:32.990 --> 02:38.180
So here I click on those dots I click on my account and I go to the account settings.

02:38.180 --> 02:43.400
And to be able to send an email from the Raspberry Pi, we will need to create what's called an app

02:43.400 --> 02:44.240
password.

02:44.270 --> 02:44.540
Okay.

02:44.570 --> 02:46.910
So that you can use the email address here.

02:46.910 --> 02:50.060
This email address was created from an external application.

02:50.090 --> 02:52.970
And external application is going to be our Python script.

02:52.970 --> 02:56.780
And before we do this where you go to security here.

02:56.780 --> 03:00.320
And you have a two step verification.

03:00.320 --> 03:01.790
So you see for me it's.

03:01.820 --> 03:02.510
Activated.

03:02.510 --> 03:05.990
So make sure that you activate the two step verification here.

03:05.990 --> 03:09.110
That's going to be mandatory for what we need to do right now.

03:09.140 --> 03:11.690
And so how to create an app password.

03:11.690 --> 03:18.110
So the thing is this Google menu, this Google account menu and all the whole interface is changing

03:18.110 --> 03:19.280
quite frequently.

03:19.280 --> 03:23.060
So somehow recently they removed the link to the app password.

03:23.060 --> 03:25.340
So you cannot really find it from anywhere.

03:25.340 --> 03:33.560
So what you have to do is to go on this search bar here and type exactly app space passwords with an

03:33.560 --> 03:34.310
S.

03:34.910 --> 03:37.370
And you see we have the app passwords here.

03:37.700 --> 03:41.180
You type this, you click here and you will get two.

03:41.780 --> 03:43.850
All right we need to verify the phone first.

03:43.850 --> 03:46.550
So I'm going to do that okay.

03:46.550 --> 03:48.590
So I have verified my phone again.

03:48.590 --> 03:52.010
And you will get to this app passwords page.

03:52.040 --> 03:58.640
And you can see the URL is my myaccount.google.com slash app passwords.

03:58.670 --> 03:59.930
The rest doesn't matter.

03:59.930 --> 04:04.160
You can just type this exactly, and you should also get to this menu.

04:04.160 --> 04:09.830
So to send an email from the Raspberry Pi we will use the the well the email address we have created

04:09.830 --> 04:11.480
here and also a password.

04:11.480 --> 04:14.570
But that's not going to be the password of the Google account.

04:14.600 --> 04:16.820
That's going to be an app password that we create here.

04:16.820 --> 04:21.530
So for example you can let's do a test create.

04:22.130 --> 04:25.670
And you see we have a new generated app password.

04:25.670 --> 04:29.240
So this is the password that you can use in your code.

04:29.270 --> 04:30.770
Now I can click on done.

04:30.770 --> 04:32.870
And you can see I have my app password.

04:32.870 --> 04:38.720
The thing is if you didn't note this, if you didn't copy this password somewhere and if you don't remember

04:38.750 --> 04:42.230
it well, you cannot get it again, that's not the problem.

04:42.230 --> 04:43.310
You just create a new one.

04:43.340 --> 04:43.550
Okay.

04:43.580 --> 04:45.230
You can remove that one as well.

04:45.230 --> 04:47.150
So that's really not a problem.

04:47.150 --> 04:53.540
So let's create one for example Raspberry Pi email okay I create one.

04:53.990 --> 04:58.340
And what I'm going to do right now is to save this inside a file.

04:58.340 --> 05:01.580
So I could use the graphical interface, but let's use the terminal.

05:01.610 --> 05:02.060
Okay.

05:02.090 --> 05:04.940
Since we know how to use it, you open a terminal.

05:04.970 --> 05:07.220
I am in my home directory.

05:07.250 --> 05:10.010
Make sure that its home directory with CD.

05:10.160 --> 05:14.480
And then well, we're going to properly store the password later on in this section.

05:14.480 --> 05:21.170
But for now let's just create a file with nano and let's name it temp okay.

05:21.200 --> 05:22.220
For temporary file.

05:22.250 --> 05:28.160
Usually I do this if I know I'm going to use a file just for temporary moment, I name it temp for example.

05:28.160 --> 05:29.390
It doesn't really matter.

05:29.930 --> 05:32.870
And we are going to copy this.

05:32.870 --> 05:41.090
So I'm going to select control C and then how to actually paste how to copy and paste something from

05:41.090 --> 05:41.750
the terminal.

05:41.780 --> 05:45.470
Because if you do Ctrl V or Ctrl C it's not going to work.

05:45.500 --> 05:47.420
You have to do Ctrl shift.

05:47.420 --> 05:55.730
So here Ctrl shift and V and you see the text has been copied, then I'm going to do Ctrl S and Ctrl

05:55.730 --> 05:56.690
X okay.

05:56.720 --> 05:59.960
So I have my password here.

05:59.960 --> 06:02.750
And we're going to use this file later in this section.

06:02.750 --> 06:06.830
So to recap here you create a new Google account for your Raspberry Pi.

06:06.860 --> 06:09.050
You activate the two step verification.

06:09.050 --> 06:11.180
Then you go to the app passwords.

06:11.180 --> 06:14.930
You generate a new password that you copy somewhere.

06:14.930 --> 06:16.190
So anywhere it doesn't matter.

06:16.190 --> 06:18.140
You can even write it on a piece of paper.

06:18.170 --> 06:21.800
You just copy it and we're going to use that later in the course.

06:21.800 --> 06:29.330
And very important note is that when I refer to the password that we use in the code, once again it's

06:29.330 --> 06:35.270
not the password of your Google account, it's the password here, the app password that we have generated.

06:35.300 --> 06:35.480
Okay.

06:35.510 --> 06:38.870
We will never use the password of your Google account.

06:38.900 --> 06:39.140
Okay.

06:39.140 --> 06:41.630
Never write this anywhere on your Raspberry Pi.

06:41.660 --> 06:47.240
Just use the app passwords that you have generated here, and you can generate as many app passwords

06:47.240 --> 06:50.090
as you want for as many applications as you want.
