How to send Gmail using python | Just 2 lines
You can send the Gmail message with just 2 lines of python code. Let’s move on to an awesome project.
Before getting into this, we will have a python interpreter and pywhatkit packages. In this case, I will use pycharm IDE. How to install pycharm in windows: https://iterathon.tech//how-to-install-the-pycharm-in-windows/
Turn On Less Secure apps
Generally, Google turns off the less secure app access for safety reasons. But now we use the third-party module to send Gmail so we need to turn on the less secure apps access. Link to access google less secure apps: https://myaccount.google.com/lesssecureapps
Open New Projects
After opening a pycharm click on a new project and you can give it any name as a Gmail Message. In this project.
Once you have give the name and click on the create. It takes few seconds to create the project, In the current project (Gmail Message) there are some existing files are found in IDE so, delete all those files using Ctrl+A and Backspace. Now Python is ready to code before that we need one awesome python packages called pywhatkit.
Install pywhatkit
PyWhatKit is a Python library for Sending WhatsApp messages, emails and has a lot of features.
Link to PyAutoGUI package: https://pypi.org/project/pywhatkit/. After getting into the link. You need to copy the magical word to install pywhatkit. That is pip install PyAutoGUI.
Again go to the pycharm and click terminal then paste the magical word pip install pywhatkit. It takes few seconds to install packages. Once the package gets installed and then go to your project Gmail Message.
Code
This is an easy and crazy python project to send mails. Let’s further move on to the python program.
#Send gmail using python import pywhatkit pywhatkit.send_mail('sender_gmail', 'sender_gmail password', 'Subject', "message", 'Receiver_gmail')
Related Post
How to Display Alert Message using Python: https://iterathon.tech//how-to-display-alert-message-using-python/
How to Impress a Girlfriend: https://iterathon.tech//how-to-impress-a-girlfriend-using-python/
LEARN SOMETHING NEW ❣