In this tutorial, we are going to learn how to send SMS in Python. We will be using Twilio for sending SMS.
First of all, go the Twilio and create an account. You will get free trial account. And finish settings.
We have to install a module called twilio to work with Twilio client. Install it with the following command.
pip install twilio
Now, go to the Twilio Documentation on how to send SMS using Twilio client. Or follow the steps to send the SMS.
# importing the client from the twilio from twilio.rest import Client # Your Account Sid and Auth Token from twilio account account_sid = [ACCOUNT_SID] auth_token = [AUTH_TOKEN] # instantiating the Client client = Client(account_sid, auth_token) # sending message message = client.messages.create(body='Hi there! How are you?', from_=[FROM_NUM , to=[VERIFIED_NUMBER]) # printing the sid after success print(message.sid)
If the message is sent successfully, then you will get the hash code as follows without any
If you have any doubts in the tutorial, mention them in the comment section.