This package makes it easy to send notifications using InterFAX with Laravel 10.x and 11.x.
You can install this package via composer:
composer require laravel-notification-channels/interfax
The service provider gets loaded automatically.
This channel will use your InterFAX username and password. To use the channel, add this to your config/services.php
file:
...
'interfax' => [
'username' => env('INTERFAX_USERNAME'),
'password' => env('INTERFAX_PASSWORD'),
'pci' => env('INTERFAX_PCI', false),
'interval' => 15,
'chunk_size' => null,
],
...
This will load your InterFAX credentials from the .env
file. If your requests must be PCI-DSS-compliant, set INTERFAX_PCI=true
in your .env
file.
The services.interfax.interval
configuration setting is the polling interval, in seconds, for a fax if it is set to check the status until it is complete. This is optional and will default to 15 if left empty. The interval has a minimum of 10 seconds, as the outbound service in the API has a maximum freqncy of 6 requests per minute and can return errors if polled more frequently.
Faxes can sometimes take more than 10 minutes to send, so it is recommended to configure a long-running queue and to push your fax notifications to that queue. More information on configuring long-running queues can be found here.
The services.interfax.chunk_size
configuration setting is the maximum file size before the InterFAX core SDK starts chunking files. The default chunk size is 1048576. When chunking, an \Interfax\Document
object is created, but the /outbound/documents
endpoint does not exist for the PCI-DSS-compliant API. If services.interfax.pci
is set to true
, it is recommended to increase the chunk size to avoid 404 errors.
To use this package, you can create a notification class, like DocumentWasSent
from the example below, in your Laravel application. Make sure to check out Laravel's documentation for this process.
<?php
use NotificationChannels\Interfax\InterfaxChannel;
use NotificationChannels\Interfax\InterfaxMessage;
use NotificationChannels\Interfax\Contracts\InterfaxNotificationContract;
class DocumentWasSent extends Notification implements InterfaxNotificationContract
{
protected $files;
public function __construct(array $files)
{
$this->files = $files;
}
/**
* Get the notification's delivery channels.
*
* @param mixed $notifiable
* @return array
*/
public function via($notifiable)
{
return [InterfaxChannel::class];
}
public function toInterfax($notifiable): InterfaxMessage
{
return (new InterfaxMessage)
->files($this->files);
}
}
The Notifiable model will need to return a destination fax number.
public function routeNotificationForInterfax($notification)
{
if($this->fax)
return preg_replace('/[^\d]/', '', $this->fax);
return null;
}
file(string $file)
: Accepts the full path to a single file (full list of supported file types found here).
files(array $array)
: Accepts an array of file paths. If overriding the default chunk_size in the config and using an \Interfax\File
object in the array, use \NotificationChannels\Interfax\InterfaxFile
instead to automatically set the file's chunk size on initialization.
stream(Filestream $stream, string $name)
: Accepts a file stream.
addMetadata(array $data)
: Add metadata for logging purposes in case of an error.
Please see CHANGELOG for more information what has changed recently.
$ composer test
If you discover any security related issues, please email [email protected] instead of using the issue tracker.
Please see CONTRIBUTING for details.
The MIT License (MIT). Please see License File for more information.