Would you like to learn how to send an email using Python and Gmail? In this tutorial, we are going to show you how to use Python to send email notifications using the Gmail SMTP server.
• Ubuntu 20
• Ubuntu 19
• Ubuntu 18
• Python 3.8.5
Equipment list
The following section presents the list of equipment used to create this tutorial.
As an Amazon Associate, I earn from qualifying purchases.
Related tutorial – Python
On this page, we offer quick access to a list of tutorials related to Python.
Tutorial – Gmail Integration
First, we need to enable your Gmail account to receive connections from external programs.
Open your browser and access your Gmail account.
In our example, the following URL was entered in the Browser:
On the login screen, enter your Gmail username and password.
After the login, you need to access the following URL:
• https://myaccount.google.com/signinoptions/two-step-verification
Enable the two step verification on this account.
After enabling the two step verification, you need to access the following URL:
• https://security.google.com/settings/security/apppasswords
Create an application password.
Select the Gmail application and the type of device: Other.
In our example, we named the device POWERSHELL.
Click on the Generate button and take note of the randomly generated password.
Next, you need to access the following URL:
• https://accounts.google.com/DisplayUnlockCaptcha
Click on the Continue button to enable external access to your Google account.
You have finished the required steps for the Gmail integration.
The Gmail integration will solve the following error.
You have finished the Gmail integration.
Tutorial Python – Send email using Gmail
Use Python to send an email using Gmail.
If the test was successful, you will receive the sent message.
Use Python to send an email using Gmail containing an attachment.
Congratulations! You are able to use Python to send emails using Gmail.