You are here: Fax API > Fax Web Service > Code Samples > PHP Samples > Send one file attachment (e.g., PDF, DOC, HTML) to one recipient with Sendfax
PHP Faxing Samples
- Tutorial: Fax from PHP
- Send a simple ASCII-text fax using SendCharFax
- Send one file attachment (e.g., PDF, DOC, HTML) to one recipient with Sendfax
- Fax one or more files to one or more recipients with SendfaxEx_2
- Get information about one or more submitted faxes with FaxStatusEx
- Get information about one or more submitted faxes with FaxQuery
- Get information about one or more submitted faxes with FaxQuery2
- Retrieve the image of a submitted fax with GetFaxImageResult
- Cancel a pending fax with CancelFax
- Inbound: get list of inbound faxes using GetList
- Inbound: retrieve a received fax using GetImageChunk
- Deprecated Samples
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 /**************** 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 ?>