Send an SMS Message with Python
Last Updated :
28 Apr, 2025
In today's fastest-growing world, SMS is still a powerful tool by which we can reach billions of users and one can establish a connection globally. In this new world when instant messaging and social media are dominating you can feel our humble SMS outdated but you don't underestimate its power, it will remain an omnipresent tool for communication even in areas where internet access is limited. Integration of SMS in a Python application will open various exciting possibilities. With the help of Python, we can automate SMS services from automated notifications to two-factor authentication.
Send SMS Using Python
Below are some ways and techniques to send SMS using Python:
- Twilio API Integration
- Vonage API Integration
Send SMS Using Twilio API Integration in Python
Below are some of the ways by which we use Twilio API integration to send SMS in Python:
Step 1: Create a Twilio Account
If you don't have an account, then sign up at Twilio.
Twilio sign up windowsStep 2: Get Twilio Credentials
After login you will receive your Account SID and Auth Token from its dashboard.

Step 3: Get a Twilio Phone Number
Get a Twilio phone number from the Twilio console. This will be the number by which your SMS will be sent.

Step 4: Install the Twilio Python Library
Install the Twilio Python library in your system using the following command in your terminal.
pip install twilio
Step 5: Write Python Code (send_sms.py)
Now you have to write this code and replacing directed credential with your Twilio credentials and contacts.
Python
from twilio.rest import Client
# in this part you have to replace account_sid
# auth_token, twilio_number, recipient_number with your actual credential
account_sid = 'account_sid'
auth_token = 'auth_token'
twilio_number = 'twilio_number'
recipient_number = 'recipient_number'
# Create Twilio client
client = Client(account_sid, auth_token)
# Send SMS
# in body part you have to write your message
message = client.messages.create(
body='This is a new message',
from_=twilio_number,
to=recipient_number
)
print(f"Message sent with SID: {message.sid}")
Step 6: Run the script
Now, save the above python script with extension .py and run it.
python file_name.py
After running successfully, you can check your console for the message SID, and you can verify your Twilio dashboard whether the SMS was sent successfully or not.
output in terminalOutput on Target Device
output on target deviceVideo Demonstration
Send SMS in Python Using Vonage API Integration
Below are some of the ways by which we use Vonage API integration to send SMS in Python:
Step 1: Create a Vonage Account
If you don't have any account, then sign up at Vonage.
sign up windowStep 2: Get Vonage API Key and Secret
After login you will receive your Account SID and Auth Token from its dashboard.

Step 3: Install the Vonage Python Library
Install the Vonage Python library in your system.
pip install vonage
Step 4: Write Python Code (file.py)
Now you have to write this code and replacing directed credential with your Vonage credentials and contacts.
Python
import vonage
# Replace with your Vonage API key and secret
api_key = 'your_api_key'
api_secret = 'your_api_secret'
# Create a Vonage client
client = vonage.Client(key=api_key, secret=api_secret)
# Create a Vonage SMS client
sms = vonage.Sms(client)
# Replace with your phone number and the message you want to send
to_number = 'recipient_phone_number'
message = 'This is a message from vonage'
# Send SMS
response = sms.send_message({
'from': 'Vonage API',
'to': to_number,
'text': message
})
# Check the response
if response['messages'][0]['status'] == '0':
print(
f"SMS sent successfully to {to_number}. Message ID: {response['messages'][0]['message-id']}")
else:
print(
f"Failed to send SMS. Error: {response['messages'][0]['error-text']}")
Step 5: Run the Script
Now, save the above python script with extension .py and run it.
python file_name.py
After running successfully, you can check your console for the message SID, and you can verify your Twilio dashboard whether the SMS was sent successfully or not.

Output

Conclusion
In conclusion, we can definitely say that sending SMS with Python or SMS automation can unease true potential of SMS, as one can have global reach, easy integration, enhance user management, easy advertisement with low cost and developer friendly ecosystem.
Similar Reads
Send message to FB friend using Python
The power of Python comes because of the large number of modules it has. This time we are going to use one of those. Every one of us, one time or another, has a wish of the message (or spamming -.-) our Facebook friend. This is a program that can do something similar. So without further delay, letâs
3 min read
Python - API.send_direct_message() in Tweepy
Twitter is a popular social network where users share messages called tweets. Twitter allows us to mine the data of any user using Twitter API or Tweepy. The data will be tweets extracted from the user. The first thing to do is get the consumer key, consumer secret, access key and access secret from
2 min read
Send message to Telegram user using Python
Have you ever wondered how people do automation on Telegram? You may know that Telegram has a big user base and so it is one of the preferred social media to read people. What good thing about Telegram is that it provides a bunch of API's methods, unlike Whatsapp which restricts such things. So in t
3 min read
Send SMS with REST Using Python
In this article, we are going to see how we can send SMS with REST using Python. The requests library can be used to make REST requests using Python to send SMS. Approach:You need to first create a REST API KEY for sending SMS using Python Script. We have used Fast2SMS for creating API KEY.You can
2 min read
Python Tkinter - Message
Python offers multiple options for developing a GUI (Graphical User Interface). Out of all the GUI methods, Tkinter is the most commonly used method. It is a standard Python interface to the Tk GUI toolkit shipped with Python. Python with Tkinter is the fastest and easiest way to create GUI applicat
3 min read
Sending SMS from Python with Google Cloud Functions
In this article, we are going to talk about how we are going to send SMS (Short Message Services) with the addition of the Powers of Google Cloud Functions. Combining it with Twilio which is a cloud communications platform that provides APIs for sending and receiving SMS messages, as well as other c
5 min read
Python Tkinter - MessageBox Widget
Python Tkinter - MessageBox Widget is used to display the message boxes in the python applications. This module is used to display a message using provides a number of functions. Python offers multiple options for developing GUI (Graphical User Interface). Out of all the GUI methods, tkinter is the
2 min read
How to Send Email with Django
Django, a high-level Python web framework, provides built-in functionality to send emails effortlessly. Whether you're notifying users about account activations, sending password reset links, or dispatching newsletters, Djangoâs robust email handling system offers a straightforward way to manage ema
4 min read
Send Emails Using Python
By using Python, you can send emails which can be a valuable skill for automation, communication, and data-driven processes. In this article, we will explore how to send mail from Gmail using Python. How can you send Emails using Python?Python offers a library to send emails- "SMTP" Library. "smtpli
4 min read
How to Send Automated Email Messages in Python
In this article, we are going to see how to send automated email messages which involve delivering text messages, essential photos, and important files, among other things. in Python. We'll be using two libraries for this: email, and smtplib, as well as the MIMEMultipart object. This object has mul
6 min read