This article is going to be about how can we send text messages using Python. We will be using Fast2SMS API to send messages. You don’t need to install any Python package for this purpose.
First, you need a Fast2SMS account. You can sign up for Fast2SMS from here. Now, go to Dev API option and copy the API Authorization Key. This API key is generated by Fast2SMS, however, you can regenerate the API key if you want to. Now, all you have to do is to make a POST request to Fast2SMS API with your API key, message, recipient, etc. and it will send your SMS.
Now, We will create two dictionaries, one for the SMS data and another for the headers.
Now, we are ready to post our data to the API.
['Message sent successfully to NonDND numbers']
If the message is sent successfully, It will print a success message. Your mobile number will be displayed to the recipient with your message.
In case of an error, it will print the Error message.
For example, if your API key is changed or you have entered the wrong API key, the following error message will be printed.
Invalid Authentication, Check Authorization Key
Attention geek! Strengthen your foundations with the Python Programming Foundation Course and learn the basics.
To begin with, your interview preparations Enhance your Data Structures concepts with the Python DS Course.
- Send SMS updates to mobile phone using python
- How to send SMS alert using Python and MSG91 API
- Automate Instagram Messages using Python
- Different messages in Tkinter | Python
- Send mail from your Gmail account using Python
- Send mail with attachment from your Gmail account using Python
- Python | Send SMS using Twilio
- Send message to Telegram user using Python
- Send Direct Message On Instagram using Selenium in Python
- Send PDF File through Email using pdf-mail module
- Python | Find current weather of any city using openweathermap API
- Convert Text and Text File to PDF using Python
- Creating a Keras Callback to send notifications on WhatsApp
- Python: Convert Speech to text and text to Speech
- Kivy - Python Framework for Mobile App development
- Analyzing Mobile Data Speeds from TRAI with Pandas
- Speech Recognition in Python using Google Speech API
- Python | Get a set of places according to search query using Google Places API
- Get emotions of images using Microsoft emotion API in Python
- Python | URL shortener using tinyurl API
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. 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.