The HTML content been sent for the FAX via RingCentral API is not getting formatted in proper order.
The code I had used:
// The HTML content to be sent
$html = "<h3>Notification</h3><div>Lorem epsum Lorem epsum Lorem epsum Lorem epsum <b>My Site</b>Lorem epsum Lorem epsum</div><div><br></div><div>Lorem epsumLorem epsumLorem epsum<i><b>Lorem epsumLorem epsumLorem epsum</b></i>.</div><div><br></div><div>To view more and print more details, please log in to <a href='http://www.demo.mysite.com' target='_blank'>www.demo.mysite.com</a> using your email address.</div><div><br></div><div>Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum</div>";
// Creating a file
$fileRand = rand();
$filename = 'faxfile_'.$fileRand.'.html';
// Open the file in write mode
$faxFile = fopen('ringfax/'.$filename, 'w');
// Write the contents to the html file.
fwrite($faxFile, $html);
// Close the file.
fclose($faxFile);
// Setting up data for the RingCentral API
$faxData['Username'] = "XXXXXXXXXX";
$faxData['Password'] = "XXXXXXXXXX";
$faxData['Recipient'] = "XXXXXXXXXX";
$faxData['Sendtime'] = gmdate('d:m:y h:m');
$faxData['Coverpage'] = 0;
$faxData['Attachment'] = '@'.realpath('ringfax/'.$filename).';filename='.$filename.';content-type=text/html';
// Open connection
$ch = curl_init();
// Set the url, number of POST vars and other data
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_URL, 'https://service.ringcentral.com/faxapi.asp?');
curl_setopt($ch, CURLOPT_HTTPHEADER, array("Accept: text/html", "charset: UTF-8"));
curl_setopt($ch, CURLOPT_POST, count($faxData));
curl_setopt($ch, CURLOPT_POSTFIELDS, $faxData);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
// Execute post
$result = curl_exec($ch);
// Receives curl error
$cErr = curl_error($ch);
// curl curl info
$cInfo = curl_getinfo($ch);
// Write the error to the log file
ini_set("log_errors", 1);
ini_set("error_log", "logs/ring_central_error");
error_log($result);
//close connection
curl_close($ch);
// Delete the file
unlink('ringfax/'.$filename);
The fax is getting sent but the content in the FAX is not getting formatted like we wanted it to be. The content in the FAX is looking something like:
Notification Lorem epsum Lorem epsum Lorem epsum Lorem epsum My Site Lorem epsum Lorem epsumLorem epsumLorem epsumLorem epsum Lorem epsumLorem epsumLorem epsum To view more and print more details, please log in to www.demo.mysite.com using your email address.Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum.
I am pretty sure that it must be the header type or something that is not getting set properly and that is why the RingCentral API is behaving like this.
Thanks in advance.
It looks like you are using the old version of the fax API. Could you kindly take a look at the API in the developer guide here :
https://developer.ringcentral.com/api-docs/latest/index.html#!#FaxMessages.html