Send one file attachment (e.g., PDF, DOC, HTML) to one recipient with Sendfax
This sample demonstrates how to send an "attached" file, such as Word DOC, PDF, or HTML to a single recipient.
It uses method Sendfax.
<?php /**************** Settings begin **************/ $username = ''; // Insert your InterFAX username here $password = ''; // Insert your InterFAX password here $faxnumber = ''; // Enter the destination fax number here, e.g. +497116589658 $filename = 'test.pdf'; // A file in your filesystem $filetype = 'PDF'; // File format; supported types are listed at // http://www.interfax.net/en/help/supported_file_types /**************** Settings end ****************/ // Open File if( !($fp = fopen($filename, "r"))){ // Error opening file echo "Error opening file"; exit; } // Read data from the file into $data $data = ""; while (!feof($fp)) $data .= fread($fp,1024); fclose($fp); $client = new SoapClient("http://ws.interfax.net/dfs.asmx?WSDL"); $params->Username = $username; $params->Password = $password; $params->FaxNumber = $faxnumber; $params->FileData = $data; $params->FileType = $filetype; $result = $client->Sendfax($params); echo $result->SendfaxResult; // returns the transactionID if successful // or a negative number if otherwise ?>
