How to Send Fax using FreeSWITCH
You can transmit electronic documents to a destination fax machine using FreeSWITCH or Asterisk.
Now in this tutorial we will show you the most common configuration and focus on simplest way to
run your Fax Command via FreeSWITCH.
Only TIFF documents can be transmitted, however it is possible to convert a number of graphical formats to TIFF format.
STEP 1:
First of all you should install Dependencies.
tiff2pdf command line
CentOS:
CentOS
Shell
12 | yum install ghostscriptyum install libtiff |
Ubuntu:
Ubuntu:
Shell
12 | apt-get install ghostscriptapt-get install libtiff-tools |
this script important to convert document to TIFF format.
Ghostscript is the key tool for converting PDF files to FAX compatible TIFF files. You may see other programs being used for this job, but behind the scenes they usually use Ghostscript to do the hard work.
You can use Ghostscript for PDF/PS files. Here is an example, producing a standard resolution TIFF file.
Shell
1 | gs -q -r204x98 -g1728x1078 -dNOPAUSE -dBATCH -dSAFER -sDEVICE=tiffg3 -sOutputFile=txfax.tiff — txfax.pdf |
Here is an example producing a fine resolution TIFF file:
Shell
1 | gs -q -r204x196 -g1728x2156 -dNOPAUSE -dBATCH -dSAFER -sDEVICE=tiffg3 -sOutputFile=txfax.tiff — txfax.pdf |
STEP 2:
Setting up your gateway provider number that support VoIP service.
${CONF}/sip_profiles/external/90XXXXXXXXXX.xml
${CONF}/sip_profiles/external/90XXXXXXXXXX.xml
XHTML
123456789 | <include> <gateway name=”90XXXXXXXXXX”> <param name=”username” value=”90XXXXXXXXXX”/> <param name=”password” value=”YOURVOIPPASSWORD”/> <param name=”realm” value=”sip.voipcomapny.com”/> <param name=”proxy” value=”sip.voipcomapny.com”/> <param name=”register” value=”true”/> </gateway></include> |
STEP 3:
After restart your freeswitch by typing service freeswitch restart
, now we are ready to originate fax call to your destination fax number, go to cd /usr/local/freeswitch/bin
and type ./fs_cli
you will start freeswitch command line program to execute the following code:
Shell
1 | originate {ignore_early_media=true,absolute_codec_string=’PCMU,PCMA’,fax_enable_t38=true,fax_verbose=true,fax_use_ecm=true,fax_enable_t38_request=true}sofia/gateway/90XXXXXXXXXX/909999999999 &txfax(‘/path/to/file/sample.tiff’) |
And if this fails further retries with:
Shell
1 | originate {ignore_early_media=true,absolute_codec_string=’PCMU,PCMA’,fax_enable_t38=true,fax_verbose=true,fax_use_ecm=false,fax_enable_t38_request=false}sofia/gateway/90XXXXXXXXXX/909999999999 &txfax(‘/path/to/file/sample.tiff’) |
Follow the log result you will see if Fax has been received successfully.
If it not received check your sample.tiff format it should be compatible with tiff fax standart mode.
or check your installed codic “PCMU,PCMA” inside freeswitch.
Common Issues:
- Remote machine doesn’t support T38 (properly or at all), this is going to make things worse and is obviously common with PSTN machines.
- A T38 gateway (or multiple) end up inbetween each transcode is going to hurt the chances of success
- Carrier/Provider doesn’t support T38 well or is poor quality for standard codecs – Some carriers end up using several other carriers and the more carriers a call goes through or the lower the quality of carrier/route the harder (and sometimes much harder) faxing can be. A quality carrier is extremely important.
- Some remote fax machines and PSTN lines can also be of low quality so while you may eventually be able to get good success overall some machines may prove to always be a challenge.
- Make sure your tiff is at the right size, there are many sizes supported by fax machines but 1728×1078 is probably the most common (and is at standard resolution). Its roughly 204x98dpi, “super fine” faxes are at higher resolutions. Ensuring the proper resolution and size is an important step to working with many remote fax machines.
- Ensure you have ignore_early_media enabled, without it random/out of order media can screw things up
- For your codecs you generally want to force PCMU/PCMA unless you know of success with something else better thats generally going to give you the best results.
- Requesting T38 can sometimes hurt your chances by things that don’t properly handle or understand T38 causing it to drop.