Forwarding Recordings to Your Email

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.

/* Your email address. */
$to = "";
$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.

Legal Implications of Call Recording

If you choose to record calls, you need to comply with certain laws and regulations, including those regarding obtaining consent to record (such as California’s Invasion of Privacy Act and similar laws in other jurisdictions). Additional information on the legal implications of call recording can be found here.

Notice: Twilio recommends that you consult with your legal counsel to make sure that you are complying with all applicable laws in connection with communications you record or store using Twilio.

Have more questions? Submit a request
Powered by Zendesk