Call files to send fax out via new context

I’m messing around with a hacked up version of the email2fax script for pushing faxes out via the Digium fax application.
This works well enough for sending a fax through, unmodified.

It generates call files that look like this:(number changed to protect our receptionist!)

Channel: DAHDI/g0/95551234
MaxRetries: 3
RetryTime: 300
WaitTime: 45
Application:SendFAX
Data: /tmp/email2fax/1259086256-158201156/subnetting.pdf.tif
#Set: EMAILADDR=$SENDER
#Set: FULLPATH=$DATADIR/$ATTNAME.tif
#Set: FAXRCPT=$FAXNUM

I’d like to use a call file that uses the context [faxout] as established in my extensions_override_freepbx.conf -
My goal is to be able to push some variables from the call file into the dialplan so I can return an email to the sender reporting success or failure of the fax based on statuses in asterisk.

Channel: DAHDI/g0/95551234 MaxRetries: 3 RetryTime: 300 WaitTime: 45 Set: EMAILADDR= [email protected] Set: FULLPATH=/tmp/email2fax/1259086256-158201156/subnetting.pdf.tif Set: FAXRCPT=95551234 Context: faxout Archive: Yes My [faxout] context looks like this: [faxout] exten => send,1,NoOp(**** SENDING FAX ****) exten => send,n,Wait(6) exten => send,n,Set(GLOBAL(FAXCOUNT)=$[ ${GLOBAL(FAXCOUNT)} + 1 ]) exten => send,n,Set(FAXCOUNT=${GLOBAL(FAXCOUNT)}) exten => send,n,Set(FAXFILE=$FULLPATH) ; Set FAXOPTs exten => send,n,NoOp(**** SETTING FAXOPT ****) exten => send,n,Set(FAXOPT(ecm)=yes) exten => send,n,Set(FAXOPT(headerinfo)=Fax from ${GLOBAL(LASTFAXCALLERNAME)} at ${GLOBAL(LASTFAXCALLERNUM)} was received.) exten => send,n,Set(FAXOPT(localstationid)=2085552208) exten => send,n,Set(FAXOPT(maxrate)=14400) exten => send,n,Set(FAXOPT(minrate)=2400) ; Send the fax exten => send,n,NoOp(**** SENDING FAX : ${FAXFILE} ****) exten => send,n,SendFAX(${FAXFILE},d) ;Check session # and Success ; Hangup! Print FAXOPTs exten => h,1,NoOp(FAXOPT(ecm) : ${FAXOPT(ecm)}) ;exten => h,n,NoOp(FAXOPT(filename) : ${FAXOPT(filename)}) ;exten => h,n,NoOp(FAXOPT(headerinfo) : ${FAXOPT(headerinfo)}) ;exten => h,n,NoOp(FAXOPT(localstationid) : ${FAXOPT(localstationid)}) ;exten => h,n,NoOp(FAXOPT(maxrate) : ${FAXOPT(maxrate)}) ;exten => h,n,NoOp(FAXOPT(minrate) : ${FAXOPT(minrate)}) ;exten => h,n,NoOp(FAXOPT(pages) : ${FAXOPT(pages)}) ;exten => h,n,NoOp(FAXOPT(rate) : ${FAXOPT(rate)}) ;exten => h,n,NoOp(FAXOPT(remotestationid) : ${FAXOPT(remotestationid)}) ;exten => h,n,NoOp(FAXOPT(resolution) : ${FAXOPT(resolution)}) ;exten => h,n,NoOp(FAXOPT(status) : ${FAXOPT(status)}) ;exten => h,n,NoOp(FAXOPT(statusstr) : ${FAXOPT(statusstr)}) ;exten => h,n,NoOp(FAXOPT(error) : ${FAXOPT(error)}) ;send email to the sender notifying of status exten => h,1,system(/var/lib/asterisk/bin/faxout-process.pl --to ${EMAILADDR} --from [email protected] --subject "Fax to ${FAXRCPT}"; exten => h,2,Hangup() yes, that's copy and paste from the digium fax manual.

I’ve hacked up the faxout-process.pl so it will send the email to the sender from a command line. I’m just having problems getting the call file to move any information through the faxout context. (and place the call)

full log is showing this:
[Nov 24 10:47:54] WARNING[3028] pbx_spool.c: At least one of app or extension must be specified, along with tech and dest in file /var/spool/asterisk/outgoing/fax-1259088474-525900514.call
[Nov 24 10:47:54] WARNING[3028] pbx_spool.c: Invalid file contents in /var/spool/asterisk/outgoing/fax-1259088474-525900514.call, deleting
[Nov 24 10:47:54] WARNING[3028] pbx_spool.c: Failed to scan service ‘/var/spool/asterisk/outgoing/fax-1259088474-525900514.call’

Thanks for any pointers in the right direction

1 Like

Alright - getting closer. It’s dialing and sending faxes, my only issue now is the fact that I’m getting double notice emails. (one with variables set, another with empty variables)

Callfile I’m generating looks like this:

Channel: Local/99@faxout/n
MaxRetries: 1
RetryTime: 300
WaitTime: 45
Set: [email protected]
Set: FULLPATH=/tmp/email2fax/1259173915-011703175/subnetting.pdf.tif
Set: FAXRCPT=DAHDI/g0/366
set: FAXNUM=366
Context: faxout
Extension: 1
Priority: 1
Archive: Yes

My context for [faxout] looks like this:

[faxout]
exten => 1,1,Answer()
exten => 1,n,Dial(${FAXRCPT})
exten => 1,n,Hangup(2) ;This should jump to Hangup Priority 2 and skip the script

exten => 99,1,Answer()
exten => 99,n,NoOp(**** SENDING FAX )
exten => 99,n,Wait(6)
exten => 99,n,Set(FAXNUM=${FAXNUM})
exten => 99,n,Set(FAXFILE=${FULLPATH})
; Send the fax
exten => 99,n,NoOp(
SENDING FAX : ${FAXFILE} ****)
exten => 99,n,SendFAX(${FAXFILE})
; Hangup! Print FAXOPTs
exten => 99,n,NoOp(FAXOPT(status) : ${FAXOPT(status)})
exten => 99,n,NoOp(FAXOPT(statusstr) : ${FAXOPT(statusstr)})
exten => 99,n,NoOp(FAXOPT(error) : ${FAXOPT(error)})
exten => 99,n,Set(FAXSTATUS=${FAXOPT(status)})
exten => 99,n,Set(FAXSTATUSSTR=${FAXOPT(statusstr)})
exten => 99,n,Set(FAXERROR=${FAXOPT(error)})
exten => 99,n,Hangup(1)
;send email to the sender notifying of status
exten => h,1,system(/var/lib/asterisk/bin/faxout-process.pl --to ${EMAILADDR} --from [email protected] --subject “Fax to ${FAXNUM}” --status “${FAXSTATUS}” --statusstr “${FAXSTATUSSTR}” --error “${FAXERROR}” --faxnum “${FAXNUM}”;
exten => h,2,Hangup

The faxout-process.pl is sending two emails. I think because both extensions in the call file are “falling through” the context and hitting the hangup section.

the log looks like this:

– Channel ‘Local/99@faxout-2193;2’ fax session ‘41’ is complete, result: ‘SUCCESS’ (FAX_SUCCESS), error: ‘NO_ERROR’, pages: 1, resolution: ‘204x196’, transfer rate: ‘9600’, remoteSID: ‘unknown’
– Executing [99@faxout:8] NoOp(“Local/99@faxout-2193;2”, “FAXOPT(status) : SUCCESS”) in new stack
– Executing [99@faxout:9] NoOp(“Local/99@faxout-2193;2”, “FAXOPT(statusstr) : FAX_SUCCESS”) in new stack
– Executing [99@faxout:10] NoOp(“Local/99@faxout-2193;2”, “FAXOPT(error) : NO_ERROR”) in new stack
– Executing [99@faxout:11] Set(“Local/99@faxout-2193;2”, “FAXSTATUS=SUCCESS”) in new stack
– Executing [99@faxout:12] Set(“Local/99@faxout-2193;2”, “FAXSTATUSSTR=FAX_SUCCESS”) in new stack
– Executing [99@faxout:13] Set(“Local/99@faxout-2193;2”, “FAXERROR=NO_ERROR”) in new stack
– Executing [99@faxout:14] Hangup(“Local/99@faxout-2193;2”, “1”) in new stack
== Spawn extension (faxout, 99, 14) exited non-zero on ‘Local/99@faxout-2193;2’
– Executing [h@faxout:1] System(“Local/99@faxout-2193;2”, "/var/lib/asterisk/bin/faxout-process.pl --to [email protected] --from [email protected] --subject “Fax to 366” --status “SUCCESS” --statusstr “FAX_SUCCESS” --error “NO_ERROR” --faxnum “366"”) in new stack
– Executing [h@faxout:2] Hangup(“Local/99@faxout-2193;2”, “”) in new stack
== Spawn extension (faxout, h, 2) exited non-zero on ‘Local/99@faxout-2193;2’
– Executing [h@faxout:1] System(“Local/99@faxout-2193;1”, "/var/lib/asterisk/bin/faxout-process.pl --to [email protected] --from [email protected] --subject “Fax to 366” --status “” --statusstr “” --error “” --faxnum “366"”) in new stack
– Channel ‘DAHDI/2-1’ fax session ‘42’ is complete, result: ‘SUCCESS’ (FAX_SUCCESS), error: ‘NO_ERROR’, pages: 1, resolution: ‘204x196’, transfer rate: ‘9600’, remoteSID: ‘unknown’

Any suggestions on how I can eliminate the double email notification?

Kirk.

1 Like