This is a simple project that receives a webhook from a Twilio SMS and sends an email with the message.
- PHP 8.2
- A Twilio account
- A Twilio phone number
git clone [email protected]:DionPotkamp/twilio-sms.git
cd twilio-sms
composer install
cp .env.example .env
- Set the webhook URL to POST
https://example.com/twilio.php
in the Twilio console.
- Set the
TWILIO_AUTH_TOKEN
in the.env
file. - Set the
EMAIL_FROM
andEMAIL_TO
in the.env
file. - Optionally set the SMTP server settings in the
.env
file.
- Start the PHP built-in server with
php -S localhost:8000 -t public
to test locally. - Send an SMS to the Twilio phone number once deployed.
twilio-sms/
├── composer.json
├── composer.lock
├── .env
├── /vendor
├── /src
│ ├── Controller
│ │ └── TwilioController.php
│ ├── Service
│ │ ├── MailService.php
│ │ └── TwilioService.php
│ └── Utils
│ ├── Logger.php
│ └── TwilioRequestValidator.php
├── /public
│ ├── index.php
│ └── twilio.php
├── /config
│ └── config.php
├── /logs
│ └── app.log
└── /tests # todo ;P
└── TwilioControllerTest.php
composer install --no-ansi --no-dev --no-interaction --no-plugins --no-progress --no-scripts --optimize-autoloader