As we know Python is a cool scripting language and can be used to write scripts to easify day-to-day task. Also, since python has large community support and lots of module/API available, it makes Python more versatile and popular among users.
In this article, we will see how to use Twilio API to send SMS using Python. It will be a very quick and easy guide to doing this very interesting task.
Firstly, we need to create an account in Twilio’s official website to get the id and token. This is a paid service, but you will be credited with an initial amount to get you started.
Steps to create Twilio account:
Head to Twilio’s registration page. Complete the registration by filling in with the required details.

From the console(dashboard), copy the ACCOUNT SID and AUTH TOKEN.

Install Twilio library using pip.
pip install twilio

Below is the Python implementation:
# importing twilio from twilio.rest import Client # Your Account Sid and Auth Token from twilio.com / console account_sid = 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'auth_token = 'your_auth_token' client = Client(account_sid, auth_token) ''' Change the value of 'from' with the number received from Twilio and the value of 'to' with the number in which you want to send message.'''message = client.messages.create( from_='+15017122661', body ='body', to ='+15558675310' ) print(message.sid) |
In the above code, just replace the values of account_sid and auth_token with the values you receive from Twilio. Also, replace the body with the message which you want to send and bingo!
Exercise:
Extract emails from your account and forward the subject and receivers mail address as a text message to your mobile phone. You can even filter it by limiting it to forward only important mails.
Recommended Posts:
- Send SMS updates to mobile phone using python
- How to send SMS alert using Python and MSG91 API
- Python | SMS Bomber using Selenium
- Send mail from your Gmail account using Python
- Send mail with attachment from your Gmail account using Python
- Send message to Telegram user using Python
- Send Text messages to any mobile number using Fast2SMS API in Python
- Send PDF File through Email using pdf-mail module
- Creating a Keras Callback to send notifications on WhatsApp
- Python | Create video using multiple images using OpenCV
- Python | Create a stopwatch using clock object in kivy using .kv file
- Image resizing using Seam carving using OpenCV in Python
- Python | Visualizing O(n) using Python
- Python - Read blob object in python using wand library
- Creating and updating PowerPoint Presentations in Python using python - pptx
- Circular (Oval like) button using canvas in kivy (using .kv file)
- Cartooning an Image using OpenCV - Python
- Using Iterations in Python Effectively
- Create a Website Alarm Using Python
- Whatsapp using Python!
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.

