How can I forward Recordings to my email inbox?

It is possible to forward voicemail or other recordings made with Twilio’s <Record> verb to your email inbox.

The following TwiML will give Twilio instructions to make a recording. Once the recording is made, Twilio will make a request to “mail.php” containing both the parameters from the Twilio Request and the <Record> request parameters:

<?xml version="1.0" encoding="UTF-8"?>
  <Record action="mail.php" />

This PHP code parses the incoming request from Twilio, then sends an email to the address you specify:

 * This section ensures that Twilio gets a response.
header('Content-type: text/xml');
echo '<?xml version="1.0" encoding="UTF-8"?>';
echo '<Response></Response>'; //Place the desired response (if any) here.

 * This section actually sends the email.
$to      = ""; // Your email address.
$subject = "Message from {$_REQUEST['From']}";
$message = "You have received a message from {$_REQUEST['From']}.";
$message .= "To listen to this message, please visit this URL: {$_REQUEST['RecordingUrl']}";
$headers = "From:"; // Who should it come from?

mail($to, $subject, $message, $headers);

Any of the parameters which are part of the Twilio Request can also be used.