Email to Fax .txt, .doc file extensions

Status
Not open for further replies.

kt351b

Member
Feb 24, 2020
33
0
6
25
Hello!
I set up Email to fax and it works great with .pdf and .tif documents. Now I want to send .txt or .doc or any other file type that can be converted by libreoffice to .pdf.
I installed: "libreoffice libreoffice-base libreoffice-common libreoffice-java-common" and added at Default Settings --> Fax --> allowed_extension .txt, .doc --> Reload
When I send a fax file "NotPdfFax.txt' or "DOCFax.docx" (both are attached) from the web-page via the "New" (using app/fax/fax_send.php script) it works, but when I send an email to use email-to-fax and run the script https://SERVERS_IP/app/fax/fax_emails.php, I got the error at fs_cli:
2021-01-25 18:44:55.218929 [ERR] mod_spandsp_fax.c:1430 Cannot send non-existant fax file [/var/lib/freeswitch/storage/fax/fortest/2005/temp/e4288435-88a6-405f-a9b2-1567af53e70f.tif]
and:
2021-01-25 18:45:49.978922 [ERR] mod_lua.cpp:202 ...eeswitch/scripts/app/fax/resources/script
s/hangup_rx.lua:62: attempt to index local 'x' (a nil value)
stack traceback:
...eeswitch/scripts/app/fax/resources/scripts/hangup_rx.lua:62: in function 'shell_esc'
...eeswitch/scripts/app/fax/resources/scripts/hangup_rx.lua:212: in main chunk


I looked at the lua script, line 212:
cmd = cmd .. "name="..quote(shell_esc(fax_file)).." ";

It looks like /app/fax/fax_send.php script didn't convert the file from .txt to .pdf and then to .tif and that's why scripts can't find it.

So, my question is: is it possible to send a fax using email to fax functionality from the "vanilla installation" with .txt attachment or I have to change the scripts to make it possible?
Thanks in advance!
 

Attachments

  • NotPdfFax.txt
    12 bytes · Views: 6
  • DefaultFaxSettings.png
    DefaultFaxSettings.png
    162.1 KB · Views: 18

Metcom

New Member
Apr 19, 2020
15
1
3
59
compare fax_email.php
//handle attachments (if any)
$emailed_files = Array();
$attachments = $message['attachments'];
if (sizeof($attachments) > 0) {
foreach ($attachments as &$attachment) {
$fax_file_extension = pathinfo($attachment['name'], PATHINFO_EXTENSION);

//block unknown files
if ($fax_file_extension == '') {continue; }
//block unauthorized files
if (!$fax_allowed_extension['.' . $fax_file_extension]) { continue; }
//support only attachments
//if($attachment['disposition'] != 'attachment'){ continue; }
to fax send.php
//process uploaded or emailed files (if any)
$fax_page_count = 0;
$_files = (!$included) ? $_FILES['fax_files'] : $emailed_files;
unset($tif_files);
foreach ($_files['tmp_name'] as $index => $fax_tmp_name) {
$uploaded_file = (!$included) ? is_uploaded_file($fax_tmp_name) : true;
if ( $uploaded_file && $_files['error'][$index] == 0 && $_files['size'][$index] > 0 ) {
//get the file extension
$fax_file_extension = strtolower(pathinfo($_files['name'][$index], PATHINFO_EXTENSION));
if ($fax_file_extension == "tiff") { $fax_file_extension = "tif"; }

//block unauthorized files
$disallowed_file_extensions = explode(',','sh,ssh,so,dll,exe,bat,vbs,zip,rar,z,tar,tbz,tgz,gz');
if (in_array($fax_file_extension, $disallowed_file_extensions) || $fax_file_extension == '') { continue; }

played around with trying to match but the best I got was send ok but some pages were garbage

I'm not a programmer just a old technician trying to get email to fax working for some old clients
 
Status
Not open for further replies.