Skip to content

Latest commit

 

History

History
85 lines (56 loc) · 3.06 KB

sending-an-incoming-fax-to-email.md

File metadata and controls

85 lines (56 loc) · 3.06 KB

Sending an incoming fax to email

  1. Add a new dialplan application (see Dialplan Applications).

Creating a new dialplan application

  1. Assign an internal number, for example, 2200110.

Parameters for dialplan

  1. Insert the following code into the "Programme Code" tab:
<?php
require_once 'Globals.php';

use \MikoPBX\Core\Asterisk\AGI;
use MikoPBX\Core\System\Notifications;
use MikoPBX\Core\System\{MikoPBXConfig};

$agi     = new AGI();
$faxFile = "/tmp/" .$agi->get_variable("CDR(linkedid)", true).'.tiff';
$caller  = $agi->get_variable("CALLERID(num)", true);
$agi->exec("ReceiveFax", "{$faxFile},d"); 
$result  = $agi->get_variable("FAXOPT(status)", true);

if($result === 'SUCCESS' && file_exists($faxFile)){
    $notify = new Notifications();
    $notify->sendMail('your-email@gmail.com', 'Fax msg from '.$caller, 'Incoming fax <br><br>', $faxFile);
    unlink($faxFile);
}
sleep(1);

{% hint style="success" %} In the code, replace 'your-email@gmail.com' with your own email address. {% endhint %}

Code for dialplan

  1. Go to the "System file customization" section.

System file customization section.

  1. Open the "extensions.conf" file for editing.

extensions.conf file

  1. Add the folowwing code to the end of file:
[SIP-1687941868-incoming](+)
exten => fax,1,Goto(internal,2200100,1)

Replace "2200100" with the number of your application.

In the code, replace "SIP-1687941868" with your provider's ID. You can find it in the provider's card in the browser's address bar.

Provider ID

  1. Open the "modules.conf" file for editing.

Modules.conf file

  1. Add the following code to the end of the file:
load => res_fax.so
load => res_fax_spandsp.so

Code for Modules.conf

  1. In the provider's card, in the advanced settings, in additional parameters, specify:
[endpoint]
fax_detect=yes
fax_detect_timeout=30

Additional parameters in Provider section