External R.S.V.P. service, hello, everyone.
Hello, everyone.
Even though almost all of the Internet service providers are working with the same type of protocol,
there are some quite huge benefits of working with them, external SMTP protocol.
So you basically have better delivery of emails and you don't need to configure your own server like
we actually did the last time.
With the Gmail.
So obvious to hear, you need to send the SMP server if you're working with Gmail, just would be Centipede
Dota Gmail dot com.
You need an SMP user, which is going to be you is going to be your Gmail account.
Actually you need your Gmail password and also the S.A.T. report, which is usually the default port
of a phone.
Four hundred and sixty five and four TSL is going to be five hundred and eighty seven.
So obviously here we're also going to use the Thai Airways, which is basically the security encryption
protocol.
But what is the good thing here is that you can simply enable Gmail to work with Python and send emails
externally.
So first of all, in order to enable that option for the Gmail to work with external service, you actually
need to update your security settings directly inside your Gmail and how you can do that.
So what you need to do is to simply go on my account dot Google dot com and then do slash less secure
apps.
OK, so once you go here, you can allow other apps to work with your Gmail.
So just enable this option here and you can see that now is updated so you can use it.
And once you update it now we can work with external apps and make them send emails from your Gmail.
So now let's move to the terminal and I will show you a script that does this.
So as we are here, guys, we can now proceed with actually sending email with Python.
So lame, create a new file.
So the new file and I would call the file exter now and Gmail.
OK, let's hit OK here.
And the file is now created and let's actually write, first of all, the steps that you would need
in order to complete this project.
So the first thing that we will need to do is to create a safety p object to connect to the server.
OK, let me go a bit closer.
So this will be the first step, then the second step.
What we're going to do is to log into our accounts.
So log in to account.
OK, then step three here would be to define headers for the message and log in created those.
OK, step for step four is going to be to create a eight, a mime multipart message object.
And basically this object is going to attach to the header that we created earlier on.
Then in step five, we're going to actually attach the message to the mime Muthee part.
Object then in step six, which is going to be the final one, we send the message.
OK, so we just heard all the steps, guys, that will fall in our cold.
And now since we're aware of what we need to do in the cold, let's actually do the cold.
So, as I said, the first thing we will do is from email dot mym dot muj part, import mym muj part.
Then from email dot my dot text will import again my text so we can write our text.
And finally, let's import s.m T.P Library and Werdum.
So now as I said, the first step here is to create the SFP object.
This is simple.
Let's write message equals MYM Muj parts.
OK, so our object is created.
The images are the brackets here.
Um then let's import import get pass class.
And now the username and password.
This time we're going to do a little bit differently because what they want to do is to enable the user
that uses the code to type his email and password.
OK, so they are not going to be predefined.
And this right here, user name equals input.
And then I will write you a user name, OK?
And then for the password, I will do the same.
So I will OK, let's for the password because who would not want to see the password in front of the
screen.
So you don't want the person that watches the screen to see your password.
So there are some specific use for that reason.
And this is the get passed method that we just imported here.
So let's to get pass, not get pass and will do prompt equals and here our right password and that's
it.
Everything that you type after just keyword password is not going to be visible, but you actually type
and validate your actual password.
OK, so step two is completed and we or extra step three and we added our creditors and let's assume
that you're already logged in from the browser.
Now let's set the parameters here.
So for the methods parameters, who are going to use the username, the password and actually the subject
of all of our emails.
So I will create first variable message that we created earlier on.
OK, the message and I'm going to parse the different variable.
So let's write from OK, so the sender is going to be equal to the user name.
OK, so it will be the user name that we have here then the receiver for simplicity.
I'm going to make the same email to send email to ourselves.
OK, so I right here again, user name.
And then message and here I right subject and here is the subject of the email sending email to myself.
OK, so this is a subject and now we can add the message, board it.
So the message board is very simple to add.
You just typed message dot attach and then in the brackets will write my text.
OK, because with the touch text in here, I will write a simple text.
Hello, this is an e-mail from your self.
To your self.
It is fun, isn't it?
OK, and then right, chroma plane.
And you're ready with this land, so this will be the message that you're going to send to yourself.
OK, now let's write a server.
So server will be equal to SMPTE P library, OK, dot s empty P and here I will write the same P dot
Gmail dot com.
OK, so this is the server address and the port is going to be five eight seven.
You can see that the server is a little bit different way comparing to our previous declaration here.
So here we use the same type of library and latitude with comma, but in that case we still use the
same type of library.
But we just added it into a different way.
Both ways obviously work so you can use either of them.
And then Lizardo server dot start here with in this line here is simply for the encryption of our protocol.
So the message gets encrypted and then decrypt it once it has been received.
OK, so after we setup everything, we need to log in to our creditors in order to send the email right.
We need to have access to our email.
So since we already have our password and the email that are provided by the user of this script now,
we would like to use them in order to be able to.
Go inside your email, so I'll write a server.
Not log in, OK, and here in the break, it's a right message and then from.
OK, common password.
Actually, his passport and I don't know why he is here, but I would definitely remove them.
OK, so here is how, Logan.
OK, so we definitely need to alter the password and the messages to the front person, which is equal
to our username, which is the user name that the user provided here, OK.
And then we use a password that's been provided as well.
Now finally, after we stop everything we are loading, we set it up what the message is going to be
and everything.
Now it's time to simply send the message.
So in the next three lines, I will write how you can send the message.
So actually, you are doing this in one line.
I will do server dot login.
Actually, send the mail, OK, and then that's right, message and then from.
OK, so this is the user would send the message from the message and then to.
OK, so as you can see, first define the user within the message from then you define the user that
was send the message to.
And finally, you need to state the message that you're going to send.
So the message you're going to send is a message which is of a type if you give me a chance, you or
type my Muja part.
OK, so this is your actual message to which you passed all the user names, the topic and so on.
So this is the final product and you send it as a string.
So as string.
OK, here we go.
And let's print then that we're successful.
So if there are no errors, so we successfully send the email or sent to email and then we'll say to
which email.
So let's write percent is OK and write a percent.
And then in the brackets, message two.
OK, so the person that will receive the message would like to display that will send a message to him.
And finally, let's exit the server so the server quit and that's it here.
So we are ready.
Guys, this is all the comments you need to add in order to send emails.
You don't need to use any intention levels for a while, loops and whatsoever.
You just need to know the comments and the posts you are sending the emails to.
So let's save this.
And I will go to a terminal now and let's write Elway's so you can see that here is the external Gmail.
So let's do Python, Python and then external Gmail dot p way.
Let's run it.
And those that were asked for username.
So my username is P White Yaniv at Gmail dot com.
OK, and then the password I will type of course will not be able to see it and then we're getting on
there probably a little typo.
So let's see what it is.
It is on line.
Twenty three years so I can see the mistake is actually quite obvious.
I don't ask here the parentheses so I will do it right now.
OK, and let's try again.
So I'll run the same thing.
OK, and then.
Let's run it.
So you can see that here I get the message successfully sent to email PVA unfettered Gmail dot com,
OK, which means that the email was sent.
So let's try it once again and let me show you a picture, not a picture, but like my email from the
browser so you can see if the email is actually being sent or not.
OK, so this is my email and let's run the code once again.
So I'll write a few way Yanov at Gmail dot com and then I'll type my password.
OK, and let's see if the e-mail is going to be handed.
I get the message successfully sent to email Piana at Gmail dot com and let's see if the message is
actually going to be sent here.
Let's reboot our email and you can see that in eight forty six pm my time like.
So immediately after we send this you can see it's 846.
The message has been sent.
So if we open it you can see that the subject is sending email to myself, which is exactly which is
exactly what we actually wrote in the cold here.
Email to myself.
And then the text inside is the one that was stated here.
Hello, this is an email to yourself, from yourself to yourself.
It is fun, isn't it?
So this is how guys who are sending basically email from one email to another and with this type of
protocol that they just displayed you, it is way easier.
And it is actually my favorite to send automated emails.
And you see how good control you have over the user who is sending the email and over the things you
want to specify inside this email.
So I hope you really had fun with this video.
And this is going to be the end of the S empty P protocol and bear with me in the next videos in this
section because we are going to talk about other email protocols and we are going to write a lot of
phone calls.
So we still have what you see here in this section.
But that was for today.
Thank you very much for watching, guys.
And I will see you in the next video.