4 Different Ways To Send Text Messages (SMS) with Python

Learn how to send SMS in Python with Twilio, Vonage, and Plivo, plus Courier's multi-channel API. Compare setup, code samples, pros, and cons.

Updated Jul 6, 2026

With the advancement of technology and the internet, sending a message to another person has become easier. However, SMS marketing still has the highest reach and a response rate compared to the average email response rate. Therefore, SMS is a powerful tool for customer engagement that allows businesses to send timely, concise, and personalized messages.

This post discusses three different options to send text messages (SMS) with Python. I'll share each method's pros and cons, so you can select the best method that fits your needs.

1. Using Twilio API

Twilio APIs provide seamless communication with the users via voice, SMS, video, or chat. Many companies use it to send SMS notifications such as password resets or alerts.

Key Partners of Twilio SMS API

  • Uber
  • Airbnb
  • eBay
  • Marks & Spenser
  • Coca Cola

Advantages of Using Twilio SMS API

  1. Support of various programming languages.
  2. Only get charged for what you use.
  3. Easy-to-understand documentation is available.
  4. Wide community support.

Disadvantages of Using Twilio SMS API

  1. It contains a developer-first platform and may not be easily navigable for non-developers.
  2. Comparatively expensive.
  3. Not very mobile-friendly.

Tutorial: How to Send SMS Using Twilio SMS API

To use Twilio in your project, you'll need a Twilio Account. If you don't have one already, you can sign up for your free trial account here.

To send SMS, you'll also require an SMS-enabled Twilio phone number which you can search and buy from the Twilio console - Buy a Number page.

Install dependencies

You can install the Twilio library from the console if you don't already have the Python helper library installed, using pip:

pip install twilio

Initialize the dependencies

Create a file named send-sms.py and add the code below. You can find the Account SID and Auth Token in your Twilio console and set the environment variables.

import os
account_sid = os.environ['TWILIO_ACCOUNT_SID']
auth_token = os.environ['TWILIO_AUTH_TOKEN']

Send an SMS

from twilio.rest import Client
client = Client(account_sid, auth_token)
message = client.messages \
.create(
body='Hello there from Twilio SMS API',
from_ = FROM_NUMBER,
to = TO_NUMBER
)
print(message.sid)

Here, you can replace the FROM_NUMBER from the number you purchased earlier and the TO_NUMBER from the message recipient's number.

Apart from Python, Twilio provides SDKs on C#, Node.js, PHP, Java, Go, and Ruby.

2. Using Vonage API

Vonage provides a simple yet powerful way to deliver voice and SMS messages. They offer a set of APIs for sending SMS notifications, sending SMS messages in bulk, and many more. It is perfect for sales personnel, general brand owners, or comms agents who need to distribute information across multiple channels with their users.

Key partners of Vonage SMS API

  • Dominos
  • Glassdoor
  • Allstate
  • DHL
  • Zipcar

Advantages of Using Vonage SMS API

  1. Comparatively easy to set up.
  2. Both web and mobile-friendly.
  3. Verify API adds a layer of security.

Disadvantages of Using Vonage SMS API

  1. Quite expensive.
  2. Canceling the service is difficult and takes a substantial amount of time.
  3. Poor customer support.

Tutorial: How to Send SMS Using Vonage SMS API

To complete this tutorial, you'll need a Vonage Account. If you don't have one already, you can create a new account and start developing with free credit.

Install dependencies

To install the Vonage Python SDK using pip:

pip install vonage

Or to upgrade the installed Vonage Python SDK using pip:

pip install vonage --upgrade

Instead, you can clone the repository via the command line:

git clone git@github.com:Vonage/vonage-python-sdk.git

Initialize the dependencies

Now, create a file named send-sms.py and include the following code. You can find the API key and API Secret from the Vonage API dashboard.

import os
VONAGE_API_KEY = os.environ['VONAGE_API_KEY']
VONAGE_API_SECRET = os.environ['VONAGE_API_SECRET']
#Create a client instance and then pass the client to the Sms instance
client = vonage.Client(key=VONAGE_API_KEY, secret=VONAGE_API_SECRET)
sms = vonage.Sms(client)

Instead of creating a client instance, you can directly pass the key and secret to the constructor.

Send an SMS

Sending an SMS using the Vonage API is very easy, and you can use the following code to do that.

response = sms.send_message(
{
"from": VONAGE_BRAND_NAME,
"to": TO_NUMBER,
"text": "Hello there from Vonage SMS API",
}
)
if response["messages"][0]["status"] == "0":
print("Message Details: ", response)
print("Message sent successfully.")
else:
print(f"Message failed with error: {response['messages'][0]['error-text']}")

Apart from Python, Vonage SDKs are available in C#, Node.js, PHP, Ruby, Java, and .NET too.

3. Using Plivo API

Plivo is a cloud-based API platform that enables real-time communications to applications. It provides SDKs and RESTful API to integrate SMS, voice, video, push notifications, and many other forms of communication into the mobile, web, and IoT applications.

Key Partners of Vonage SMS API

  • IBM
  • Zomato
  • Accenture
  • WiX.com

Advantages of Using Vonage SMS API

  1. Easy to set up.
  2. User-friendly UI/UX.
  3. Seamless customization.

Disadvantages of Using Vonage SMS API

  1. Documentation is a bit challenging to understand.
  2. Lack of error messages.

Tutorial: How to Send SMS Using a Plivo SMS API

You need a Plivo account and an SMS-enabled phone number to get started.

Install dependencies

You can install the Plivo SDK using pip:

pip install plivo

Initialize the dependencies

Create a file named send-sms.py and add the following code to it. The Auth ID and Auth Token can be found in the Account section at the top of the Plivo console.

import os
auth_id = os.environ['PLIVO_ACCOUNT_ID']
auth_token = os.environ['PLIVO_AUTH_TOKEN']

Send an SMS

import plivo
client = plivo.RestClient('<auth_id>','<auth_token>')
message_created = client.messages.create(
src = FROM_NUMBER,
dst = TO_NUMBER,
text='Hello there from Plivo SMS API!'
)

Note that if you're using a Plivo trial account, you can only send messages using the numbers that have been verified with Plivo.

Plivo SDKs are available in .NET, Go, Java, Python, PHP, Node.js, and Ruby.

4. Using Multi-Channel Notification API

Apart from the methods mentioned above, you can use a multi-channel notification service like Courier to send SMS via a mobile notification channel that covers push, in-app, email, and more from a uniform API.

With the modern application requirements, using a multi-channel notification service like Courier can streamline your notification flow by creating all the relevant channels with them a single API.

Advantages of Using a Multichannel Notification Service

  1. You can notify users across different notification channels using a single API.
  2. You won't have to manage a large codebase since all channels use the same API.
  3. You can add more notification channels without modifying your code.
  4. As a result, your notification service can be managed by any non-technical user.

Disadvantages of Using a Multichannel Notification Service

  1. Consuming many notification channels can be costly.
  2. The maximum number of notifications you can receive per month limits you.

Tutorial: How to Send SMS Using a Multi-Channel Notification API

For this demonstration, I will be using Courier since it supports well-known SMS providers like Twilio, Plivo, MessageBird, and more.

Creating a Courier account

You can create a free Courier account by signing up at https://app.courier.com/signup.

Creating a new channel

After logging in, add an SMS provider. Open the Channels tab in the Courier dashboard, choose an SMS provider from the list (for example, Twilio, Plivo, or MessageBird), enter the credentials the provider asks for, and install it. Courier routes your SMS through whichever provider you configure, so you can switch or add providers later without changing your code.

Creating a notification

Open the Designer tab and create a notification. Add an SMS channel, then compose the message body. Publish your changes so the template is ready to send.

Install the Courier SDK

Install the Courier Python SDK using pip:

pip install trycourier

Then send your SMS notification. Store your API key in an environment variable rather than hardcoding it, and send to a user profile that already has a phone number on file:

import os
from courier import Courier
client = Courier(api_key=os.environ["COURIER_API_KEY"])
response = client.send.message(
message={
"to": {
"user_id": "user-123",
},
"template": "NEDRQK62TWM70MHT84S6FKSXM4VT",
"data": {
"name": "Nomen Nescio",
},
}
)
print(response.request_id)

Courier stores the recipient's phone number on their user profile, so you send to a user_id and Courier resolves the SMS destination for you. You can also pass a phone_number directly under to if you prefer. Replace the template value with the ID of the notification you published, and use data to pass any variables your template references.

Note: You can customize the above code based on your requirements. Refer to the Courier documentation for more details.

Frequently Asked Questions

How do I send an SMS with Python?

Install a provider SDK with pip (for example pip install twilio, pip install vonage, pip install plivo, or pip install trycourier), store your API credentials in environment variables, then call the SDK's send method with a recipient number and a message body. Each provider in this guide includes a runnable Python example.

Which is the best Python library for sending SMS?

It depends on your needs. Twilio, Vonage, and Plivo are single-provider SDKs that talk directly to one SMS gateway. Courier is a multi-channel option: one API sends SMS through providers like Twilio, Plivo, or MessageBird and can extend the same code to push, email, and in-app without a rewrite.

Do I need an SMS-enabled phone number to send texts in Python?

Yes. Twilio, Vonage, and Plivo each require an SMS-enabled number that you purchase and verify in their console. With Courier you configure the number inside the SMS provider you connect, so the number lives with that provider rather than in your Python code.

How do I send SMS to multiple recipients in Python?

Loop over a list of recipients and call the send method once per recipient, or use a provider feature built for bulk sends. With Courier you can send to a list or audience so a single API call fans out to many users across the channels you configure.

Is it free to send SMS with Python?

The SDKs are free and open source, but the SMS delivery itself is billed per message by the provider. Twilio, Vonage, and Plivo charge per SMS, and Courier bills based on notification volume across channels. Most providers offer trial credit so you can test before you pay.

Can I send more than SMS from the same Python code?

With single-provider SDKs you would integrate each channel separately. With Courier the same client.send.message call can deliver push, email, and in-app notifications alongside SMS, so you add channels by configuring them in the dashboard instead of changing your code.

Conclusion

In this article, I've discussed different service providers that you can use to send SMS with Python. With basic knowledge of Python, you should now be able to choose the most suitable provider and integrate it into your application to send SMS.

One API, every channel

Ship notifications without the boilerplate

Courier gives you one API for email, SMS, push, and chat, with templates, routing, retries, and delivery logs built in.

Last updated Jul 6, 2026. Code samples are illustrative; provider APIs and pricing change over time, so check each provider’s docs before relying on them.