Get Appointment

We have received your message and will contact you soon.

Thank you for choosing prositeweb, your web development agency in Montreal. Please call us at +1 (514) 548-2165 if you need immediate support.

Send SMS from your website with this trick. (detailed guide)

Texting from your website with Twilio can be easy, depending on the programming language you use. Email marketing and phone calls have become relatively complicated. Indeed, a study was able to show that the rate of opening emails has dropped relatively in recent years. If you have a website and are planning to try SMS marketing as an additional way to target customers, this article is for you. In this article, we look at how you can send SMS from your website with Twilio . At the end of the article, you can add the Twilio SDK to your project and add a form to send SMS. You will also see how to get a Twilio number and an API for your project.

Tutorial Prerequisite

Our article is intended for three types of profiles:

  • Developers — who want to learn how to do it themselves (follow the steps).
  • A business owner — who doesn't have enough time and wants a usable solution (Download code).
  • Any individual — who is curious and would like to learn.

Required for developers

To follow this tutorial and easily apply it to your project, you must have the following basics:

  • Basic skills in PHP.
  • Understand how HTML tags work.
  • Some web programming skills.

For a business owner

You can read the article to understand how it works. However, we have provided two options that can help you:

Please contact us if you have any questions. [the_call_to_action title="Get a copy of the code for sending SMS from your site. The code is ready to use and documented" action_text="Download" action_type="modal" action_link="exampleModal" data_title=" Get the extension download link directly in your email " data_action =" download " data_link="prositeweb_paiement"]

An approach for developers to integrate the sending of SMS

To configure being able to send SMS from your site, you must follow the steps below.

Step 1 – Create a Twilio account and get the settings

To start, you will need to create a Twilio account and acquire some parameters such as: API sid, API authentication code and phone number. For example, in your dashboard, you can create API credentials for your project. When you sign up, you get a personalized phone number that you can use to automate texting.

How to create a Twilio account

To create a Twilio account, go to and click on “register”. From there, you will see a registration form that gives you the option to try for free. The next step will be to enter the email address, then the password you need. Then the software will send you an email confirmation, from which you can approve your account and access it. Initially, you will have free credit that you can use to send SMS from your site or benefit from other Twilio services. Twilio account creation form


The procedure for creating an account on Twilio may change depending on their terms and conditions. I advise you to follow and read the steps of the registration procedure.

Get API SID and Authentication Code

After creating your account and then logging into your dashboard, you will find your Account SID then your authentication code under the Dashboard ⇒ General tab (the link is console/project/settings). You can then copy these two pieces of information for your project.

Get your Twilio account number

To get your Twilio phone number, click on the three-dot menu panel at the bottom left, then a menu tab will display the menu link. From there, you'll see a list of phone numbers under the super network heading.

Step 2 – Twilio's PHP Classes

Thanks to the PHP classes or the SDK, you will be able to easily interact with the APIs. You can either use the composer to download or do it manually. So, we generally recommend Compositor, because it downloads with all updates. A manual update may be outdated or missing a dependency. In addition, we will see how to use the two approaches:

Download using Composer and generate "Composer.phar" file.

In addition, you can find more information about using the composer on the site. Thus, you will find instructions there as well as detailed documentation on how to use the composer within the framework of a project. Note that you must have command line access to use and download the composer. Below are the general steps:

  • On the website, click the "Getting Started" button. You will see the documentation for creating the composer.phar file.

Using the command line, you can run the code below. Note that you may need to change the version of the sha256 depending on the current version. See the article on for more details. Running the above code will generate the composer.phar file. To get the composer.json file, you can do the following:

Generate the composer.json file to download the Twilio SDK

If you want to have more information on how to create the composer.json file, you can refer to the official documentation. For this tutorial, you just need to create the composer.json file and paste the following code. Then from the command line you can run the code

 composer require twilio/sdk

If you follow the instructions carefully, you will see a new folder called vendor in your main directory with some PHP files for your projects.

Include the Twilio SDK in your project

If you followed the steps above carefully, you can now include the SDK and start sending SMS from your website. The code below will help you to text anyone from your website.

Instructions for using the code
  • Replace the sid (line 9) as well as the code (line 10) with the identification you obtained in step 1.
  • You can then replace the phone number on line 16 with the recipient's phone number (the person you want to text to).
  • Finally, on line 19, you will replace the phone number with your Twilio phone number.

Step 3 – Create a form to send SMS from your website

Now that you have the code to send an SMS, you can create a form that will save you from doing it manually. For example, with the code above, you can modify the message, the recipient's phone number to send the SMS. However, if you want to automate the process, you can create a form from your dashboard to accomplish this. Below is an example of a form you can use.

Example code HTML-index.html

The HTML code corresponding to the above form is as follows.

Sample PHP-sendms.php action file code

In addition to the HTML code, we will need an action file (PHP) which will receive a variable and send it to the SMS recipient. The PHP action may look like the code below:


The process of sending SMS from your website is quite simple with Twilio. You can use different programming languages. Also, if you have skills in developing plugins or extensions, it might be a good idea to convert it to a CMS extension. If you have any questions, please contact us; we will be happy to help you.

Share :


Creation of the Cameroon 237 Biz website
17 January 2023
Design of Shinaïs Beauty online store
09 May 2022

Do you have a project in mind? Contact our web agency for a free evaluation.

We are the experts in creating websites, online stores and functionalities for websites based in Montreal. Contact us today to create your website starting at $1,200.