Does this work for integrating with Plivo, I installed the app, but I see that in the settings there is a plivo_api_url but no plivo_auth_id or plivo_auth_token
Disclaimer: I do not use that carrier and didn't write that section of code that handles Plivo, so I can't vouch for it.Does this work for integrating with Plivo, I installed the app, but I see that in the settings there is a plivo_api_url but no plivo_auth_id or plivo_auth_token
echo "ok";
Might be best to start a new thread and just link to it here. If you do, please include details on what you have tried, and what exactly is or is not happening (Does thinQ show the receipt of the message? Do they show errors? Does the message get delivered to the endpoint but doesn't look right? etc.) It also helps to include (sanitized) log results from your /var/log/nginx/error.log.Has anyone gotten this to work using thinQ? I'm mostly concerned with inbound SMS and having difficulty.
Great, I will do just that!Might be best to start a new thread and just link to it here. If you do, please include details on what you have tried, and what exactly is or is not happening (Does thinQ show the receipt of the message? Do they show errors? Does the message get delivered to the endpoint but doesn't look right? etc.) It also helps to include (sanitized) log results from your /var/log/nginx/error.log.
In general, while I do not use thinQ, someone added it to the integration several years ago and theoretically it worked at that time. It'll just be a matter of debugging.
Msg: MMS Message received, see attachment--
==Multipart_Boundary_x33841fa48df5ecbc2f23291f4780c374x
Content-Type: image/jpeg;
name = "0035894183d467fde82b2795989375c5ad1fa17538a3b0388f15b76c1a7cf968.jpeg"
Content-Disposition: inline;
filename = "0035894183d467fde82b2795989375c5ad1fa17538a3b0388f15b76c1a7cf968.jpeg"
Content-Transfer-Encoding:base64
I'm assuming this is not for Telnyx, since that is fully tested? I'm not sure how much I can help, but here goes:I am trying to get MMS working. However whenever the email is sent it seems the headers are being sent in the body and I am receiving what I believe is the base64 encoded data for the attachment. This is what comes through in my email, followed by the base64 data. Any ideas on where I can look or what to change?
$email_message = "This is a multi-part message in MIME format.\n\n" .
"--{$mime_boundary}\n" . "Content-Type:text/html; charset = \"iso-8859-1\"\n" .
"Content-Transfer-Encoding: 7bit\n\n" . $email_txt . "\n\n";
Thank you for the insight. It is for Telnyx. I will double check the email_value and test tonight when I have a chance, however I have not made any edits after following the GitHub install instructions.I'm assuming this is not for Telnyx, since that is fully tested? I'm not sure how much I can help, but here goes:
It sound like you have something not quite right in file sms_email.php, in the "if ($carrier == "<your_carrier_name>") block.
I would look closely at the way you are setting the $email_message value. I suspect you are missing this line, towards the top of that block and before the "for" loop:
PHP:$email_message = "This is a multi-part message in MIME format.\n\n" . "--{$mime_boundary}\n" . "Content-Type:text/html; charset = \"iso-8859-1\"\n" . "Content-Transfer-Encoding: 7bit\n\n" . $email_txt . "\n\n";
In this same file, close to the top of the send_sms_to_email function, you can also put in a "$debug = true;". Then check your nginx error log to see the output from the $email_message and make sure it has everything in it should. It will probably truncate output, which is why I usually leave $debug = false;.
This is a multi-part message in MIME format.
--==Multipart_Boundary_x33c05de0b6444c2db86b899d0dc8c512x
Content-Type:text/html; charset = "iso-8859-1"
Content-Transfer-Encoding: 7bit
To: 9XXXXXXXXMsg: MMS Message received, see attachment
--==Multipart_Boundary_x33c05de0b6444c2db86b899d0dc8c512x
Content-Type: image/jpeg;
name = "0035894183d467fde82b2795989375c5ad1fa17538a3b0388f15b76c1a7cf968.jpeg"
Content-Disposition: inline;
filename = "0035894183d467fde82b2795989375c5ad1fa17538a3b0388f15b76c1a7cf968.jpeg"
Content-Transfer-Encoding:base64
if ($carrier == "telnyx") {
if (gettype($media)=="array") {
$email_txt = 'To: ' . $to . '<br>Msg: ' . $body . '<br>MMS Message received, see attachment';
$email_message = "This is a multi-part message in MIME format.\n\n" .
"--{$mime_boundary}\n" . "Content-Type:text/html; charset = \"iso-8859-1\"\n" .
"Content-Transfer-Encoding: 7bit\n\n" . $email_txt . "\n\n";
//process MMS attachment
foreach ($media as $attachment) {
$url = $attachment->url;
$start = strrpos($url, '/') == -1 ? strrpos($url, '//') : strrpos($url, '/')+1;
$fileatt_name = substr($url, $start, strlen($url)); // Filename that will be used for the file as the attachment
if (!empty($_SESSION['sms']['mms_attachment_temp_path']['text'])) {
$fileatt = $_SESSION['sms']['mms_attachment_temp_path']['text'];
if (substr($fileatt, -1) != '/') {
$fileatt .= '/';
}
$fileatt .= $fileatt_name;
}
else {
$fileatt = '/var/www/fusionpbx/app/sms/tmp/' . $fileatt_name; // Path to the file
}
// download attachment
file_put_contents($fileatt, fopen($url, 'r'));
//$fileatt_type = "application/octet-stream"; // File Type
$fileatt_type = $attachment->content_type; // File Type
//$start = strrpos($attachment, '/') == -1 ? strrpos($attachment, '//') : strrpos($attachment, '/')+1;
$file = fopen($fileatt,'rb');
$attdata = fread($file,filesize($fileatt));
fclose($file);
$attdata = chunk_split(base64_encode($attdata));
$email_message .= "--{$mime_boundary}\n" . "Content-Type: {$fileatt_type};\n" .
" name = \"{$fileatt_name}\"\n" . "Content-Disposition: inline;\n" . " filename = \"{$fileatt_name}\"\n" .
"Content-Transfer-Encoding:base64\n\n" . $attdata . "\n\n" . "--{$mime_boundary}--\n";
error_log("email_message: " . $email_message);
unlink($fileatt); // delete a file after attachment sent.
}
}
}
Looks like you are missing a line at the bottom. It's the "$email_message .=" line.This is the code block I have after your suggested edit, it was $email_message = "" . $email_txt . "";.
This is what I receive in the body of the email, followed by the base64 encoded data. Also, the attachment is Untitled.html. I tried adding $debug=true before and after global $db, $debug, $domain_uuid, $domain_name, $carrier; but nothing showed up in the NGINX logs.
PHP:if ($carrier == "telnyx") { if (gettype($media)=="array") { $email_txt = 'To: ' . $to . '<br>Msg: ' . $body . '<br>MMS Message received, see attachment'; $email_message = "This is a multi-part message in MIME format.\n\n" . "--{$mime_boundary}\n" . "Content-Type:text/html; charset = \"iso-8859-1\"\n" . "Content-Transfer-Encoding: 7bit\n\n" . $email_txt . "\n\n"; //process MMS attachment foreach ($media as $attachment) { $url = $attachment->url; $start = strrpos($url, '/') == -1 ? strrpos($url, '//') : strrpos($url, '/')+1; $fileatt_name = substr($url, $start, strlen($url)); // Filename that will be used for the file as the attachment if (!empty($_SESSION['sms']['mms_attachment_temp_path']['text'])) { $fileatt = $_SESSION['sms']['mms_attachment_temp_path']['text']; if (substr($fileatt, -1) != '/') { $fileatt .= '/'; } $fileatt .= $fileatt_name; } else { $fileatt = '/var/www/fusionpbx/app/sms/tmp/' . $fileatt_name; // Path to the file } // download attachment file_put_contents($fileatt, fopen($url, 'r')); //$fileatt_type = "application/octet-stream"; // File Type $fileatt_type = $attachment->content_type; // File Type //$start = strrpos($attachment, '/') == -1 ? strrpos($attachment, '//') : strrpos($attachment, '/')+1; $file = fopen($fileatt,'rb'); $attdata = fread($file,filesize($fileatt)); fclose($file); $attdata = chunk_split(base64_encode($attdata)); $email_message .= "--{$mime_boundary}\n" . "Content-Type: {$fileatt_type};\n" . " name = \"{$fileatt_name}\"\n" . "Content-Disposition: inline;\n" . " filename = \"{$fileatt_name}\"\n" . "Content-Transfer-Encoding:base64\n\n" . $attdata . "\n\n" . "--{$mime_boundary}--\n"; error_log("email_message: " . $email_message); unlink($fileatt); // delete a file after attachment sent. } } }
...
unlink($fileatt); // delete a file after attachment sent.
}
$email_message .= "--{$mime_boundary}--\n";
}
}
...
Have you got it to work?This is the code block I have after your suggested edit, it was $email_message = "" . $email_txt . "";.
This is what I receive in the body of the email, followed by the base64 encoded data. Also, the attachment is Untitled.html. I tried adding $debug=true before and after global $db, $debug, $domain_uuid, $domain_name, $carrier; but nothing showed up in the NGINX logs.
PHP:if ($carrier == "telnyx") { if (gettype($media)=="array") { $email_txt = 'To: ' . $to . '<br>Msg: ' . $body . '<br>MMS Message received, see attachment'; $email_message = "This is a multi-part message in MIME format.\n\n" . "--{$mime_boundary}\n" . "Content-Type:text/html; charset = \"iso-8859-1\"\n" . "Content-Transfer-Encoding: 7bit\n\n" . $email_txt . "\n\n"; //process MMS attachment foreach ($media as $attachment) { $url = $attachment->url; $start = strrpos($url, '/') == -1 ? strrpos($url, '//') : strrpos($url, '/')+1; $fileatt_name = substr($url, $start, strlen($url)); // Filename that will be used for the file as the attachment if (!empty($_SESSION['sms']['mms_attachment_temp_path']['text'])) { $fileatt = $_SESSION['sms']['mms_attachment_temp_path']['text']; if (substr($fileatt, -1) != '/') { $fileatt .= '/'; } $fileatt .= $fileatt_name; } else { $fileatt = '/var/www/fusionpbx/app/sms/tmp/' . $fileatt_name; // Path to the file } // download attachment file_put_contents($fileatt, fopen($url, 'r')); //$fileatt_type = "application/octet-stream"; // File Type $fileatt_type = $attachment->content_type; // File Type //$start = strrpos($attachment, '/') == -1 ? strrpos($attachment, '//') : strrpos($attachment, '/')+1; $file = fopen($fileatt,'rb'); $attdata = fread($file,filesize($fileatt)); fclose($file); $attdata = chunk_split(base64_encode($attdata)); $email_message .= "--{$mime_boundary}\n" . "Content-Type: {$fileatt_type};\n" . " name = \"{$fileatt_name}\"\n" . "Content-Disposition: inline;\n" . " filename = \"{$fileatt_name}\"\n" . "Content-Transfer-Encoding:base64\n\n" . $attdata . "\n\n" . "--{$mime_boundary}--\n"; error_log("email_message: " . $email_message); unlink($fileatt); // delete a file after attachment sent. } } }
if ($carrier == "telnyx") {
if (gettype($media)=="array" && count($media)>0) {
$email_txt = 'To: ' . $to . '<br>Msg: ' . $body . '<br>MMS Message received, see attachment';
$email_message = "This is a multi-part message in MIME format.\n\n" .
"--{$mime_boundary}\n" . "Content-Type:text/html; charset = \"iso-8859-1\"\n" .
"Content-Transfer-Encoding: 7bit\n\n" . $email_txt . "\n\n";
//process MMS attachment
for ($x = 0; $x < count($media); $x++) {
$url = $media[$x]->url;
$start = strrpos($url, '/') == -1 ? strrpos($url, '//') : strrpos($url, '/')+1;
$fileatt_name = substr($url, $start, strlen($url)); // Filename that will be used for the file as the attachment
if (!empty($_SESSION['sms']['mms_attachment_temp_path']['text'])) {
$fileatt = $_SESSION['sms']['mms_attachment_temp_path']['text'];
if (substr($fileatt, -1) != '/') {
$fileatt .= '/';
}
$fileatt .= $fileatt_name;
}
else {
$fileatt = '/var/www/fusionpbx/app/sms/tmp/' . $fileatt_name; // Path to the file
}
if ($debug) {
error_log("fileatt path: " . $fileatt);
}
// download attachment
file_put_contents($fileatt, fopen($url, 'r'));
$fileatt_type = $media[$x]->content_type; // File Type
$file = fopen($fileatt,'rb');
$attdata = fread($file,filesize($fileatt));
fclose($file);
$attdata = chunk_split(base64_encode($attdata));
$email_message .= "--{$mime_boundary}\n" . "Content-Type: {$fileatt_type};\n" .
" name = \"{$fileatt_name}\"\n" . "Content-Disposition: inline;\n" . " filename = \"{$fileatt_name}\"\n" .
"Content-Transfer-Encoding:base64\n\n" . $attdata . "\n\n" ;
//error_log("email_message: " . $email_message);
unlink($fileatt); // delete a file after attachment sent.
}
$email_message .= "--{$mime_boundary}--\n";
}
}