Forwarding SMS messages to another phone number

When SMS messages are delivered to your Twilio phone number, Twilio will respond based on the application you have configured to that number. These messages are saved in your Twilio SMS logs.

If you'd like to forward SMS to your phone without needing to host your own code, you can use TwiML Bins to do this. 

Simply create a new Bin in your Twilio account and save the following code to it:

<Message to="+12065551212">{{From}}: {{Body}}</Message>

Then you can head to your Active Numbers page, set your Messaging URL to configure with "Webhooks/Twiml," and select your TwiML Bin from the available drop-down. You're all set!


Alternately, you might want to build SMS forwarding functionality from scratch and host it on your own server. If that's the case, you can use the following PHP code:

<?php header('Content-Type: text/html'); ?>
    <Message to="<?=$_REQUEST['PhoneNumber']?>"> <?=htmlspecialchars(substr($_REQUEST['From'] . ": " . $_REQUEST['Body'], 0, 1600))?> </Message>

If you save this code to your server as, then you would configure your Twilio phone number with an SMS request URL like this:

Make sure you place the phone number you want to forward SMS messages to in the PhoneNumber parameter of the URL-encoding.

Have more questions? Submit a request
Powered by Zendesk