In this repository, I am going to show how to use Python to send SMS and email for free. This is a useful feature to automate some processes. For example, you may want to create a newsletter or receive a notification when your processing ends. The process involves setting up a virtual environment and using the smtplib package. While the instructions are provided for a Windows environment with a .venv virtual environment, the process can be adapted for Conda environments and other operating systems.
It is important to mention that I am not creating this from scratch. Here are some references that I used to create it:
- https://www.youtube.com/watch?v=3247tuklMEk
- https://github.com/AdamGetbags/emailToSMS/blob/main/emailToSMSConfig.py
- https://medium.com/testingonprod/how-to-send-text-messages-with-python-for-free-a7c92816e1a4
- Ensure Python is installed on your computer.
- Create a virtual environment using the following command:
python -m venv .venv
You can replace ".venv" with a different environment name if desired. More information in this website. - Activate the virtual environment by navigating to ".venv\Scripts\activate".
- Once the virtual environment is activated, you can import the SMTP protocol client package.
I used GMAIL to send SMS and e-mail. So, I need to configure the email to use on APP password. This will allow you to send emails and SMS using Python. You can find more information in these links:
- source: YouTube
- Google App Passwords
After creating it, you need to change the EMAIL
and PASSWORD
here and here.
Unfortunately, you need to know the carrier from the phone you want to send an SMS.
You can use a .py
approach or a Jupyter Notebook
to send the SMS and e-mail. Both of them are inside this repository
-
Jupyter Notebook option: All the functions and tips are inside this Notebook. Just change for your data and give it a try.
-
Python option: If you want to run it on a larger scale,
.py
is a good option. You can run using this python file. All the configurations are inside this file.
All this is working just fine in the USA; not sure about how to adapt it for different countries.
Feel free to explore and modify the code to suit your needs!