I have the following code and a program is trying to access it but I get a 500 error. I checked the syntax and everything else was working perfectly fine.
One important thing to note is that a moved servers, and that's when I noticed this started happening but I cannot pint point on the issue.
Please note that I have changed business name, phone numbers, and emails for privacy.
<?php
require_once('PHPMailer-
master/class.phpmailer.php');
/**
* This section ensures that Twilio gets a response.
*/
header('Content-type: text/xml');
echo '<?xml version="1.0" encoding="UTF-8"?>';
$dial_call_status = $_REQUEST['DialCallStatus'];
if($dial_call_status == "completed" || $dial_call_status == "answered"){
$email = new PHPMailer();
$email->From = 'info@somedomain.com';
$email->FromName = 'Business Name';
$email->Subject = "New number calling from
{$_REQUEST['From']}";
$email->Body = "The call comes from the following city {$_REQUEST['FromCity']}, {$_REQUEST['FromState']}. Mp3 attached.";
$email->AddAddress( 'user1@somedomain.com' , 'Mar');
$email->AddAddress( 'user2@somedomain.com' , 'Rol');
$email->AddAddress( 'user3@somedomain.com' , 'Vic');
$recordingUrl = @$_REQUEST['RecordingUrl'];
$duration = @$_REQUEST['Duration'];
$durationRecording = @$_REQUEST['RecordingDuration'];
$callerId = @$_REQUEST['From'].'.mp3';
$attachment_data = file_get_contents($recordingUrl);
$email->addStringAttachment($attachment_data,$callerId, 'base64',
'audio/mpeg3');
if ($durationRecording < 1.0) {
exit;
} else {
return $email->Send();
}
}else{
?>
<Response>
<Sms from="+1555555555" to="+18188888884">Mar didn't answer the call.</Sms>
<Sms from="+1555555555" to="+18188888886">Vic, someone is calling you.</Sms>
<Pause length="4"/>
<Dial timeout="8" record="true"
action="mail1.php">
<Number url="whisper.xml">+18188888886</Number>
</Dial>
</Response>
<?php
}
?>
I also checked the syntax using
php -l mail.php
and it returned
no syntax errors detected in mail.php