Send one file attachment (e.g., PDF, DOC, HTML) to one recipient with Sendfax

25 Nov 2016 This code sample is deprecated and in process of being removed. Check out our new code libraries and usage documentation on InterFAX @ Github.

This sample demonstrates how to send an "attached" file, such as Word DOC, PDF, or HTML to a single recipient.

It uses method Sendfax.


/**************** 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 

/**************** Settings end ****************/

// Open File
if( !($fp = fopen($filename, "r"))){
    // Error opening file
    echo "Error opening file";

// Read data from the file into $data
$data = "";
while (!feof($fp)) $data .= fread($fp,1024);

$client = new SoapClient("");

$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


Contact us today

Talk to a member of our team about the benefits InterFAX can bring to your organization's communications processes.

Contact us today