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
- Send SMS updates to mobile phone using python
- How to send SMS alert using Python and MSG91 API
- 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
- Python | Find current weather of any city using openweathermap API
- Send PDF File through Email using pdf-mail module
- 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
- Python | Calculate geographic coordinates of places using google geocoding API
- Python | Get a google map image of specified location using Google Static Maps 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.