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.


<?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

?>

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