Google SecurityWe will be sending e-mails with Gmail. So, the first thing we need to do is set up Google security.On May 30th, 2022 Gmail removed the setting to allow "less secure" applications to access an account with just a username and password.What this means is that you must enable some other means of account security.One way I describe this here is to turn on two-factor authentication.To allow our Python client script to access Gmail accounts we will enable two-factor authentication (2FA) which Google calls "2-step verification".With 2FA you add an extra layer of security to your account in case your password is stolen. After you set it up, you’ll sign in to your account in two steps using:something you know, like your password andsomething you have, like your phone.To enable 2FA:1. Open your Google Account.2. In the navigation panel, select Security.3. Under “Signing in to Google,” select 2-Step VerificationClick the blue GET STARTED button:Login using your password. Make sure you are using the right account.Enter your phone number and click NEXT:Wait for the confirmation code to arrive and enter it in and click NEXT:Click the TURN ON button:2FA should now be enabled:App PasswordsNow we will generate a special password that our app can use as the 2-step verification.Back in the Signing into Google panel select "App passwords" to add a new password:Maybe ask again for the password to log in, after login.Under the "Select app" drop-down select "Other":Give your app a name and click GENERATE:Write down (copy to clipboard) your generated password to use in the app:We should now have our generated app password:import smtplibimport sslcdc = ssl.create_default_context()my_password = "abcdefghijklmno" # Your app password goes heremy_email = "somename@gmail.com" # Your e-mail addressreceiver = "recipient@gmail.com" # Recipient's addressmessage = "Hello from Python."with smtplib.SMTP_SSL("smtp.gmail.com", port=465, context=cdc) as server:server.login(my_email, my_password)server.sendmail(my_email, receiver, message)The code above creates a secure connection with Gmail’s SMTP server using Secure Sockets Layer encryption (SSL) and automatically upgrades it to TLS. Passing in the context from the create_default_context() function will load the system’s trusted CA certificates, enable certificate validation and hostname checking and try to choose reasonably secure protocol and cipher settings.Note: Be sure to fill in your password and sender and receiver strings.