How do I forward my 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 want to build SMS forwarding functionality from scratch and host it on your own server, you may also use the following code.

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

If you save this code to your server as http://example.com/sms_forward.php, then you would configure your Twilio phone number with an SMS request URL like this:

http://example.com/sms_forward.php?PhoneNumber=%2B12025551212

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