Fax to Email Issue

cathb2017
Joined: Fri 16 of Jun, 2017

Fax to Email Issue

Posted:Fri 16 of Jun, 2017 (16:35 UTC)
I think our voip system uses asterisk but excuse me if I'm wrong. We can't get fax to email to work. When we try to open the PDF file it gives the error message as follows:Adobe Acrobat Reader could not open 'fax_383838493.pdf' because it is either not a supported file type or because the file has been damaged (for example, it was sent as an email attachment and wasn't correctly decoded). It won't open in Adobe at all after trying a few versions. It does open with a freebie pdf viewer. We need it to open in Adobe. Can someone review the script and see if there is a way we can fix or perhaps even send it as a zip file? Thanks.


exten => s,1,Set(GROUP(fax)=fax)
exten => s,n,Set(FROM_DID=${CALLERID(dnid)})
exten => s,n,Set(CDR(dst)=${FROM_DID})
;
exten => s,n,Noop(Receiving Fax for: ${FAX_RX_EMAIL} , From: ${CALLERID(all)})
;
exten => s,n,NoOp(**** SETTING FAXOPT ****)
exten => s,n,Set(FAXOPT(ecm)=yes)
exten => s,n,Set(FAXOPT(headerinfo)=FAX SERVER)
exten => s,n,Set(FAXOPT(localstationid)=${FROM_DID})
;exten => s,n,Set(FAXOPT(maxrate)=14400)
;exten => s,n,Set(FAXOPT(minrate)=2400)
;
exten => s,n(receivefax),StopPlaytones
exten => s,n,ReceiveFAX(${ASTSPOOLDIR}/fax/${UNIQUEID}.tif, f)
exten => s,n,Hangup()
;
exten => h,1,NoOp(FAXOPT(status) : ${FAXOPT(status)})
exten => h,n,NoOp(FAXOPT(statusstr) : ${FAXOPT(statusstr)})
exten => h,n,NoOp(FAXOPT(error) : ${FAXOPT(error)})
exten => h,n,ExecIf($"${FAXOPT(error)}"!="" && "${FAXOPT(status)}"!="SUCCESS"?Set(FAXSTATUS=FAILED FAXOPT: error: ${FAXOPT(error)} status: ${FAXOPT(status)} statusstr: ${FAXOPT(statusstr)}))
exten => h,n,GotoIf($"${FAXSTATUS:0:6}" = "FAILED"?failed)
exten => h,n,Set(COUNTER=0)
exten => h,n(incrementcounter),Set(COUNTER=$${COUNTER} + 1)
exten => h,n,GotoIf($[${LEN(${EMAIL_$${COUNTER}})} = 0]?end)
exten => h,n,System(${ASTVARLIBDIR}/agi-bin/fax-process.pl --to ${EMAIL_${COUNTER}} --from [email protected] --dest "${FROM_DID}" --subject "New fax from ${URIENCODE(${CALLERID(name)})} ${URIENCODE(<${CALLERID(number)}>)}" --attachment fax_${URIENCODE(${CALLERID(number)})}.pdf --type application/pdf --file ${ASTSPOOLDIR}/fax/${UNIQUEID}.tif)
exten => h,n,Goto(incrementcounter)
exten => h,n(failed),Noop(FAX ${FAXSTATUS} for: ${FAX_RX_EMAIL} , From: ${CALLERID(all)})
exten => h,n,System(/usr/bin/php ${ASTVARLIBDIR}/agi-bin/sendmail.php "[email protected]" "[email protected]" "Fax Failed" "The fax gateway failed to receive a fax from ${CALLERID(number)} <${CALLERID(name)}>.\n\nError information: ${FAXSTATUS}")
exten => h,n(end),System(/bin/rm -f ${ASTSPOOLDIR}/fax/${UNIQUEID}.tif)
exten => h,n,Hangup()