PHPackages                             interfax/interfax - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [API Development](/categories/api)
4. /
5. interfax/interfax

ActiveLibrary[API Development](/categories/api)

interfax/interfax
=================

Send and receive faxes with InterFAX

v2.0.0(4y ago)132.8M↑12.2%4[1 issues](https://github.com/interfax/interfax-php/issues)2MITPHPPHP ^7.3|^7.4|^8

Since Oct 19Pushed 2y ago7 watchersCompare

[ Source](https://github.com/interfax/interfax-php)[ Packagist](https://packagist.org/packages/interfax/interfax)[ RSS](/packages/interfax-interfax/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (10)Dependencies (4)Versions (16)Used By (2)

InterFAX PHP Library
====================

[](#interfax-php-library)

[![PHP version](https://camo.githubusercontent.com/1d1dc1b7e2819b287328e6fb23609d479f99f01b7583e671bafde26b8709ab79/68747470733a2f2f62616467652e667572792e696f2f70682f696e746572666178253246696e7465726661782e737667)](https://badge.fury.io/ph/interfax%2Finterfax)[![Build status](https://camo.githubusercontent.com/a866d3c48fb1f07a5a43c7afd4840b4b78f453f5acb85a5e7cbcb39765b6a7d0/68747470733a2f2f7472617669732d63692e636f6d2f696e7465726661782f696e7465726661782d7068702e7376673f6272616e63683d6d6173746572)](https://travis-ci.com/interfax/interfax-php)

[Installation](#installation) | [Getting Started](#getting-started) | [Contributing](#contributing) | [Usage](#usage) | [License](#license)

Send and receive faxes in PHP with the [InterFAX](https://www.interfax.net/en/dev) REST API.

Installation
------------

[](#installation)

Two versions of this library exist, 1.x and 2.x. The 1.x version provides support for older versions of PHP, whilst the 2.x branch is designed to support the more recent releases of the language:

Package VersionMinimum PHP VersionMaximum PHP Version1.x5.67.22.x7.38.1### Composer

[](#composer)

The preferred method of installation is via [Packagist](http://www.packagist.org) and [Composer](http://www.composer.org). Run the following command to install the package and add it as a requirement to your project's `composer.json`:

```
composer require interfax/interfax
```

with 1.x version constraint

```
composer require interfax/interfax:"^1"
```

or with 2.x version constraint

```
composer require interfax/interfax:"^2"
```

### Download the release

[](#download-the-release)

You can download the package in its entirety (from 1.0.2 onward). The [Releases](https://github.com/interfax/interfax-php/releases) page lists all stable versions. Download any file with the name `interFAX-PHP-[RELEASE_NAME].zip` for a package including this library and its dependencies.

Uncompress the zip file you download, and include the autoloader in your project:

```
require_once '/path/to/interFAX-PHP-[RELEASE_NAME]/vendor/autoload.php';
```

You may wish to rename the release folder to not include the RELEASE\_NAME, so that you can drop in future versions without changing the include.

### Build it yourself

[](#build-it-yourself)

The [installation](INSTALLATION.md) docs explain how to create a standalone installation.

Getting started
---------------

[](#getting-started)

To send a fax for a pdf file:

```
use Interfax\Client;

$interfax = new Client(['username' => 'username', 'password' => 'password']);
$fax = $interfax->deliver(['faxNumber' => '+11111111112', 'file' => 'folder/file.pdf']);

// get the latest status:
$fax->refresh()->status; // Pending if < 0. Error if > 0

// Simple polling
while ($fax->refresh()->status < 0) {
    sleep(5);
}
```

Usage
=====

[](#usage)

[Client](#client) | [Account](#account) | [Outbound](#outbound) | [Inbound](#inbound) | [Documents](#documents) | [Helper Classes](#helper-classes) | [Query Parameters](#query-parameters) | [Exceptions](#exceptions)

Client
------

[](#client)

The client follows the [12-factor](http://12factor.net/config) apps principle and can be either set directly or via environment variables.

```
$client = new Interfax\Client(['username' => '...', 'password' => '...']);

// Alternative: will utilise environment variables:
// * INTERFAX_USERNAME
// * INTERFAX_PASSWORD

$client = new Interfax\Client();
```

### Send a Fax

[](#send-a-fax)

To send a fax, call the deliver method on the client with the appropriate array of parameters.

```
$client = new Interfax\Client(['username' => '...', 'password' => '...']);
$fax = $client->deliver([
    'faxNumber' => '+442086090368',
    'file' => __DIR__ . '/../tests/Interfax/test.pdf'
]);
```

The `deliver` method will take either a `file` or `files` argument. The `files` is an array of file values.

Each `file` entry can be:

- local path - if the file is larger than the allowed limit, it will be automatically uploaded as an `Interfax\Document`
- uri (from an `Interfax\Document`)
- an array defining a streamed resource (see below)
- `Interfax\File`
- `Interfax\Document`

#### Sending a stream

[](#sending-a-stream)

Because of the high degree of flexibility that PHP stream resources offer, it's not practical to retrieve information automatically from a stream to send as a fax. As such, there are certain required parameters that must be provided:

```
$stream = fopen('/tmp/fax.pdf', 'rb');
$fax = $client->deliver([
    'faxNumber' => '+442086090368',
    'file' => [$stream, ['name' => 'fax.pdf', 'mime_type' => 'application/pdf']]
```

Note that it is assumed that the stream will not exceed the file size limitation for an inline file to be sent. However, if a size parameter is provided for the stream, and this exceeds the limit, it will be automatically uploaded as a `Interfax\Document`

[Documentation](https://www.interfax.net/en/dev/rest/reference/2918)

Account
-------

[](#account)

### Balance

[](#balance)

Determine the remaining faxing credits in your account.

```
echo $client->getBalance();
// (string) 9.86
```

**More:** [documentation](https://www.interfax.net/en/dev/rest/reference/3001)

Outbound
--------

[](#outbound)

[Get list](#get-outbound-fax-list) | [Get completed list](#get-completed-fax-list) | [Get record](#get-outbound-fax-record) | [Get image](#get-outbound-fax-image) | [Cancel fax](#cancel-an-outbound-fax) | [Search](#search-fax-list) | [Resend fax](#resend-a-fax)

`Interfax\Client` has an outbound property that can be accessed:

```
$outbound = $client->outbound;
```

### Get outbound fax list

[](#get-outbound-fax-list)

```
$faxes = $client->outbound->recent();
// Interfax\Outbound\Fax[]
```

**Options:** [`limit`, `lastId`, `sortOrder`, `userId`](https://www.interfax.net/en/dev/rest/reference/2920)

---

### Get completed fax list

[](#get-completed-fax-list)

```
$fax_ids = [ ... ]; // array of fax ids
$client->outbound->completed($fax_ids);
// Interfax\Outbound\Fax[]
```

### Get outbound fax record

[](#get-outbound-fax-record)

`$client->outbound->find(fax_id)`

Retrieves information regarding a previously-submitted fax, including its current status.

```
$fax = $client->outbound->find(123456);
//Interfax\Outbound\Fax || null
```

[Documentation](https://www.interfax.net/en/dev/rest/reference/2921)

### Get outbound fax image

[](#get-outbound-fax-image)

`$client->outbound->find(fax_id)->image()`

The image is retrieved via a method on the outbound fax image object.

```
$fax = $client->outbound->find(123456);
if ($fax) {
    $image = $fax->image();
    $image->save('path/to/save/file/to.tif');
}
```

### Cancel an outbound fax

[](#cancel-an-outbound-fax)

`$client->outbound->find(fax_id)->cancel();`

A fax is cancelled via a method on the `Interfax\Outbound\Fax` model.

```
$fax = $client->outbound->find(123456);
if ($fax) {
    $fax->cancel();
}
```

### Search fax list

[](#search-fax-list)

`$client->outbound->search($options)`

Search for outbound faxes with a hash array of options keyed by the accepted search parameters for the outbound search API endpoint.

```
$faxes = $client->outbound->search(['faxNumber' => '+1230002305555']);
// Interfax\Outbound\Fax[]
```

**Options:** [`ids`, `reference`, `dateFrom`, `dateTo`, `status`, `userId`, `faxNumber`, `limit`, `offset`](https://www.interfax.net/en/dev/rest/reference/2959)

### Resend a Fax

[](#resend-a-fax)

`$client->outbound->resend($id[,$newNumber])`

Resend the fax identified by the given id (optionally to a new fax number).

```
$fax = $client->outbound->resend($id);
// Interfax\Outbound\Fax sent to the original number
$fax = $client->outbound->resend($id, $new_number);
// Interfax\Outbound\Fax sent to the $new_number
```

Returns a new `Interfax\Outbound\Fax` representing the newly created outbound fax.

Inbound
-------

[](#inbound)

[Get list](#get-inbound-fax-list) | [Get record](#get-inbound-fax-record) | [Get image](#get-inbound-fax-image) | [Get emails](#get-forwarding-emails) | [Mark as read](#mark-as-readunread) | [Resend to email](#resend-inbound-fax)

`Interfax\Client` has an `inbound` property that supports the API endpoints for receiving faxes, as described in the [Documentation](https://www.interfax.net/en/dev/rest/reference/2913)

```
$inbound = $client->inbound;
//Interfax\Inbound
```

### Get inbound fax list

[](#get-inbound-fax-list)

`$inbound->incoming($options = []);`

Retrieves a user's list of inbound faxes.

```
$faxes = $inbound->incoming();
//\Interfax\Inbound\Fax[]
$faxes = $inbound->incoming(['unreadOnly' => true ...]); // see docs for list of supported query params
//\Interfax\Inbound\Fax[]
```

[Documentation](https://www.interfax.net/en/dev/rest/reference/2935)

---

### Get inbound fax record

[](#get-inbound-fax-record)

`$inbound->find($id);`

Retrieves a single fax's metadata (receive time, sender number, etc.).

```
$fax = $inbound->find(123456);
//\Interfax\Inbound\Fax || null
```

null is returned if the resource is not found. Note that this could be because the user is not permissioned for the specific fax.

[Documentation](https://www.interfax.net/en/dev/rest/reference/2938)

---

### Get inbound fax image

[](#get-inbound-fax-image)

`$inbound->find($id)->image()`

The image is retrieved via a method on the inbound fax object.

```
$fax = $client->inbound->find(123456);
if ($fax) {
    $image = $fax->image();
    $image->save('path/to/save/file/to.pdf');
}
```

[Documentation](https://www.interfax.net/en/dev/rest/reference/2937)

---

### Get forwarding emails

[](#get-forwarding-emails)

`$inbound->find($id)->emails()`

The forwarding email details are retrieved via a method on the inbound fax object.

```
$fax = $client->inbound->find(123456);
if ($fax) {
    $emails = $fax->emails(); // array structure of forwarding emails.
}
```

The returned array is a reflection of the values returned from the emails endpoint of the REST API:

```
[
    [
       'emailAddress' => 'username@interfax.net',
       'messageStatus' => 0,
       'completionTime' => '2012-0623T17 => 24 => 11'
    ],
    //...
];
```

[Documentation](https://www.interfax.net/en/dev/rest/reference/2930)

---

### Mark as read/unread

[](#mark-as-readunread)

`$inbound->find($id)->markRead();``$inbound->find($id)->markUnread();`

The inbound fax object provides methods to change the read status.

```
$fax = $client->inbound->find(123456);
if ($fax) {
    $fax->markUnread(); // returns true
    $fax->markRead(); //returns true
}
```

[Documentation](https://www.interfax.net/en/dev/rest/reference/2936)

---

### Resend inbound fax

[](#resend-inbound-fax)

`$inbound->find($id)->resend();`

The resend method is on the inbound fax object.

```
$fax = $client->inbound->find(123456);
if ($fax) {
    $fax->resend();
}
```

---

Documents
---------

[](#documents)

[Create](#create-document) | [Upload chunk](#upload-chunk) | [Properties](#document-properties) | [Cancel](#cancel-document)

The `Interfax\Document` class allows for the uploading of larger files for faxing. The following is an example of how one should be created:

```
$document = $client->documents->create('test.pdf', filesize('test.pdf'));
$stream = fopen('test.pdf', 'rb');
$current = 0;
while (!feof($stream)) {
    $chunk = fread($stream, 500);
    $end = $current + strlen($chunk);
    $doc->upload($current, $end-1, $chunk);
    $current = $end;
}
fclose($stream);
```

### Create document

[](#create-document)

```
$params = [...]; // see documentation for possible params
$document = $client->documents->create($filename, filesize($filename), $params);
// Interfax\Document
```

[Documentation](https://www.interfax.net/en/dev/rest/reference/2967)

### Upload chunk

[](#upload-chunk)

```
$document->upload($start, $end, $data); // returns the document object.
```

Note no verification of data takes place - an exception wil be raised if values do not match appropriately.

### Document properties

[](#document-properties)

As per the [documentation](https://www.interfax.net/en/dev/rest/reference/2965) a Document has a number of properties which are accessible:

```
$document->status;
$document->fileName;
$document->refresh()->attributes();
```

```
$document->location;
// or as returned by the API:
$document->uri;
```

### Cancel document

[](#cancel-document)

`$document->cancel(); //returns the $document instance`

Can be done prior to completion or afterward

Helper Classes
--------------

[](#helper-classes)

### Outbound Fax

[](#outbound-fax)

The `Interfax\Outbound\Fax` class wraps the details of any fax sent, and is returned by most of the `Outbound` methods.

It offers several methods to manage or retrieve information about the fax.

```
// fluent methods that return the $fax instance
$fax->refresh(); // refreshes the data on the fax object
$fax->cancel(); // cancel the fax, returns true on success
$fax->hide(); // hides the faxes from the fax lists

$image = $fax->image(); // returns Interfax\Image
$new_fax = $fax->resend('+1111111'); // returns a new Interfax\Outbound\Fax
$fax->attributes(); // hash array of fax data properties - see details below
```

### Outbound fax properties

[](#outbound-fax-properties)

Properties on the Fax vary depending on which method call has been used to create the instance. Requesting a property that has not been received will raise a SPL `\OutOfBoundsException`

[Documentation](https://www.interfax.net/en/dev/rest/reference/2921)

These are all accessible on a fax instance:

```
echo $fax->completionTime
echo $fax->duration
...
```

Note values will all be returned as strings.

For convenience, a hash array of the properties can be retrieved

```
$fax->attributes();
```

Status should always be available. The values of the status codes are [Documented here](https://www.interfax.net/en/help/error_codes)

### Inbound Fax

[](#inbound-fax)

The incoming equivalent of the outbound fax class, the `Interfax\Inbound\Fax` class wraps the details of any incoming fax, and is returned by the `Interfax\Inbound` methods where appropriate.

```
// fluent methods that return the $fax instance for method chaining
$fax->refresh(); // reload properties of the inbound fax
$fax->markRead(); // mark the fax read - returns true or throws exception
$fax->markUnread(); // mark the fax unread - returns true or throws exception
$fax->resend();

$image = $fax->image(); // Returns a Interfax\Image for this fax
$email_array = $fax->emails(); // see below for details on the structure of this array
$fax->attributes(); // hash array of properties
```

Query parameters
----------------

[](#query-parameters)

Where methods support a hash array structure of query parameters, these will be passed through to the API endpoint as provided. This ensures that any future parameters that might be added will be supported by the API as is.

The only values that are manipulated are booleans, which will be translated to the text 'TRUE' and 'FALSE' as appropriate.

[Documentation](https://www.interfax.net/en/dev/rest/reference/2927)

Exceptions
----------

[](#exceptions)

Any method call that involves a call to the Interfax RESTful API may throw an instance of `Interfax\Exception\RequestException`.

An exception is thrown for any requests that do not return a successful HTTP Status code. The goal of this Exception is to provide a convenience wrapper around information that may have been returned.

Certain responses from the API will provide more detail, and where this occurs, it will be appended to the message of the Exception.

```
try {
    $interfax->deliver(...);
} catch (Interfax\Exception\RequestException $e) {
    echo $e->getMessage();
    // contains text detail that is available
    echo $e->getStatusCode();
    // the http status code that was received
    throw $e->getWrappedException();
    // The underlying Guzzle exception that was caught by the Interfax Client.
}

```

Contributing
------------

[](#contributing)

1. **Fork** the repo on GitHub
2. **Clone** the project to your own machine
3. **Commit** changes to your own branch
4. **Push** your work back up to your fork
5. Submit a **Pull request** so that we can review your changes

### Which version of the library?

[](#which-version-of-the-library)

Functionality for the API in both versions of the library should be the same, and its therefore intended that the core code continues to be the same in both versions. The differences primarily exist to enable continuity of test coverage as PHP evolves (and phpunit evolves with it)

As such, the core functionality should be developed in a way that will work with PHP 5.6 and up, and be consistent in both versions. Usage of newer language features in PHP will not be accepted in the core code.

### Running tests

[](#running-tests)

Ensure that composer is installed, then run the following commands.

```
composer install
./vendor/bin/phpunit
```

License
-------

[](#license)

This library is released under the [MIT License](LICENSE).

###  Health Score

43

—

FairBetter than 91% of packages

Maintenance18

Infrequent updates — may be unmaintained

Popularity48

Moderate usage in the ecosystem

Community20

Small or concentrated contributor base

Maturity71

Established project with proven stability

 Bus Factor1

Top contributor holds 83% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~144 days

Recently: every ~103 days

Total

15

Last Release

1482d ago

Major Versions

v1.2.0 → v2.0.02022-04-27

PHP version history (2 changes)v1.2.0PHP ~5.6|^7.0|^7.1|^7.2

v2.0.0PHP ^7.3|^7.4|^8

### Community

Maintainers

![](https://www.gravatar.com/avatar/17a4aed22337e5f23eff29909a9fd1d0192208c058a687e34556068dd86adb16?d=identicon)[splatEric](/maintainers/splatEric)

![](https://www.gravatar.com/avatar/196f353d583f5f27568e1cc3bb791c9e202455a2b830a123c4d94387fea10574?d=identicon)[Upland InterFAX](/maintainers/Upland%20InterFAX)

---

Top Contributors

[![splatEric](https://avatars.githubusercontent.com/u/2445288?v=4)](https://github.com/splatEric "splatEric (137 commits)")[![ricky-shake-n-bake-bobby](https://avatars.githubusercontent.com/u/39415009?v=4)](https://github.com/ricky-shake-n-bake-bobby "ricky-shake-n-bake-bobby (23 commits)")[![cbetta](https://avatars.githubusercontent.com/u/7718?v=4)](https://github.com/cbetta "cbetta (5 commits)")

---

Tags

faxfax-apihipaainboundinterfaxinterfax-apilibraryonline-faxoutboundphpreceivesdksend

###  Code Quality

TestsPHPUnit

Code StylePHP\_CodeSniffer

### Embed Badge

![Health badge](/badges/interfax-interfax/health.svg)

```
[![Health](https://phpackages.com/badges/interfax-interfax/health.svg)](https://phpackages.com/packages/interfax-interfax)
```

###  Alternatives

[tencentcloud/tencentcloud-sdk-php

TencentCloudApi php sdk

3731.2M42](/packages/tencentcloud-tencentcloud-sdk-php)[convertkit/convertkitapi

Kit PHP SDK for the Kit API

2167.1k1](/packages/convertkit-convertkitapi)[mapado/rest-client-sdk

Rest Client SDK for hydra API

1125.9k2](/packages/mapado-rest-client-sdk)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
