Call files to send fax out via new context

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