<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html; charset=ISO-8859-1"
http-equiv="Content-Type">
</head>
<body bgcolor="#ffffff" text="#000000">
Try put the php in the AGI directory and call it via AGI() in
Asterisk.<br>
<br>
Jian <br>
<br>
On 11-08-24 10:21 AM, Tim King wrote:
<blockquote
cite="mid:CAAKbpsU9nAu=NkYstkTPN=+xF=gLavYy2Ad-1oWPyzRHSmeFwg@mail.gmail.com"
type="cite"><b>I have been testing this for a week now, and I am
still struggling to make it work. Here is the output from
extension 11 just to show that permissions are correct and
asterisk can access faxnotify.php</b><br>
<br>
-- Executing [11@outb2:1] Verbose("SIP/616818xxxx-000002f6",
"Testing....") in new stack<br>
Testing....<br>
-- Executing [11@outb2:2] Set("SIP/616818xxxx-000002f6",
"FNAME=/var/lib/asterisk/bin/faxnotify.php") in new stack<br>
-- Executing [11@outb2:3] Verbose("SIP/616818xxxx-000002f6",
"Size: 2553") in new stack<br>
Size: 2553<br>
-- Executing [11@outb2:4] Verbose("SIP/616818xxxx-000002f6",
"Mode: 100777") in new stack<br>
Mode: 100777<br>
-- Executing [11@outb2:5] Verbose("SIP/616818xxxx-000002f6",
"#!/usr/bin/php<br>
<?php<br>
<br>
// set some global variables here<br>
$SUCCESS_STATUS = "FAX_SUCCESS";<br>
$FROM_EMA") in new stack<br>
#!/usr/bin/php<br>
<?php<br>
<br>
// set some global variables here<br>
$SUCCESS_STATUS = FAX_SUCCESS;<br>
$FROM_EMA<br>
-- Executing [11@outb2:6] TrySystem("SIP/616818xxxx-000002f6",
"/var/lib/asterisk/bin/faxnotify.php") in new stack<br>
-- Executing [11@outb2:7] Verbose("SIP/616818xxxx-000002f6",
"SUCCESS") in new stack<br>
SUCCESS<br>
-- Executing [11@outb2:8] Hangup("SIP/616818xxxx-000002f6",
"") in new stack<br>
== Spawn extension (outb2, 11, 8) exited non-zero on
'SIP/616818xxxx-000002f6'<br>
<br>
If I execute from the command line as user asterisk the script
works correctly. If i execute extension 777 test.php is called and
works correctly. The only thing I wonder is if asterisk is somehow
not correctly passing the variables to faxnotify.php causing it to
fail. Can someone please test this configuration on their system
and let me know if they see what I am doing wrong?<br>
<br>
This works as user asterisk.<br>
<b>/var/lib/asterisk/bin/faxnotify.php NOTIFY "<a
moz-do-not-send="true" href="mailto:tim.compnetwork@gmail.com">tim.compnetwork@gmail.com</a>"
"6165550000" "24/08/11 : 09:00:00" "FAX_SUCCESS" "1"</b><br>
<b><br>
Here are the permissions of the folder.<br>
</b>drwxr-xr-x 2 asterisk asterisk 4.0K Aug 24 13:19 .<br>
drwxr-xr-x 13 asterisk asterisk 4.0K Aug 22 12:38 ..<br>
-rwxrwxrwx 1 asterisk asterisk 2.5K Aug 24 11:43 faxnotify.php<br>
-rwxr-xr-x 1 asterisk asterisk 6.4K Aug 20 10:26 <a
moz-do-not-send="true" href="http://fax-process.pl">fax-process.pl</a><br>
-rwxrwxrwx 1 asterisk asterisk 73 Aug 24 12:52 test.php<br>
-rwxrwxrwx 1 asterisk asterisk 60 Aug 24 11:40 test.sh<br>
<b><br>
[outbound]</b><br>
exten => 11,1,Verbose(Testing....)<br>
exten => 11,n,Set(FNAME=/var/lib/asterisk/bin/faxnotify.php)<br>
exten => 11,n,Verbose(Size: ${STAT(s,${FNAME})})<br>
exten => 11,n,Verbose(Mode: ${STAT(m,${FNAME})})<br>
exten => 11,n,Verbose(${FILE(${FNAME},,100)})<br>
exten => 11,n,TrySystem(${FNAME})<br>
exten => 11,n,Verbose(${SYSTEMSTATUS})<br>
exten => 11,n,Hangup()<br>
<br>
exten => 777,1,System(/var/lib/asterisk/bin/test.php)<br>
exten => 777,n,Playback(vm-goodbye)<br>
exten => 777,n,Hangup()<br>
<br>
<b>[ext-fax]</b><br>
exten => s,1,Noop(Receiving Fax for: ${FAX_RX_EMAIL} , From:
${CALLERID(all)})<br>
exten => s,n(receivefax),StopPlaytones<br>
exten => s,n,ReceiveFAX(${ASTSPOOLDIR}/fax/${UNIQUEID}.tif,f)<br>
exten =>
s,n,ExecIf($["${FAXOPT(error)}"=""]?Set(FAXSTATUS=FAILED LICENSE
EXCEEDED))<br>
exten => s,n,ExecIf($["${FAXOPT(error)}"!="" &&
"${FAXOPT(error)}"!="NO_ERROR"]?Set(FAXSTATUS="FAILED FAXOPT:
error: ${FAXOPT(error)} status: ${FAXOPT(status)} statusstr: ${FAX<br>
exten => s,n,Hangup<br>
exten => h,1,GotoIf($["${FAXSTATUS:0:6}" = "FAILED"]?failed)<br>
exten => h,n(process),GotoIf($[${LEN(${FAX_RX_EMAIL})} =
0]?end)<br>
exten => h,n,System(${ASTVARLIBDIR}/bin/<a
moz-do-not-send="true" href="http://fax-process.pl">fax-process.pl</a>
--to "${FAX_RX_EMAIL}" --from "<a moz-do-not-send="true"
href="mailto:noreply@mydomain.com">noreply@mydomain.com</a>"
--dest "${FROM_DID}" --subject "New fax from ${URIENCODE(${CALLERI<br>
exten => h,n(end),Macro(hangupcall,)<br>
exten => h,process+101(failed),Noop(FAX ${FAXSTATUS} for:
${FAX_RX_EMAIL} , From: ${CALLERID(all)})<br>
exten => h,n,Macro(hangupcall,)<br>
<br>
<b>[app-fax]</b><br>
include => app-fax-custom<br>
exten => 6169804602,1,Set(FAX_RX_EMAIL=<a
moz-do-not-send="true" href="mailto:tim.compnetwork@gmail.com">tim.compnetwork@gmail.com</a>)<br>
exten => 6169804602,n,Goto(ext-fax,s,1)<br>
exten => h,1,Macro(hangupcall,)<br>
<br>
<br>
<b>test.php</b><br>
<br>
<?php<br>
exec("touch /var/lib/asterisk/bin/testfile.txt");<br>
<br>
<b>faxnotify.php</b><br>
<br>
#!/usr/bin/php<br>
<?php<br>
<br>
// set some global variables here<br>
$SUCCESS_STATUS = "FAX_SUCCESS";<br>
$FROM_EMAIL = "<a moz-do-not-send="true"
href="mailto:fax@mydomain.com">fax@mydomain.com</a>";<br>
$FROM_NAME = "mydomain Fax";<br>
$CONTACT_EMAIL = "<a moz-do-not-send="true"
href="mailto:support@mydomain.com">support@mydomain.com</a>";<br>
<br>
if ($argc != 7) {<br>
echo "Usage faxnotify.php messagetype email destination timestamp
status_string pages \n ";<br>
echo "message type can be one of INIT or NOTIFY ";<br>
}<br>
echo "Starting faxnotify.php \n";<br>
<br>
<br>
// setting up<br>
$messtype = $argv[1];<br>
$email = $argv[2];<br>
$dest = $argv[3];<br>
$timestamp = $argv[4];<br>
$status = $argv[5];<br>
$numpages = $argv[6];<br>
<br>
$headers = "From: $FROM_NAME <$FROM_EMAIL>";<br>
<br>
// end setting up<br>
<br>
if ($messtype == "INIT") { // SendFAX called successfully in the
dialplan...<br>
$emailSubject = "Your fax to $dest has been initiated";<br>
$notice = "Your fax to $dest sent on $timestamp has been
initiated. You will get a notification " .<br>
"email when the transmission is
complete. ";<br>
$emailBody = "Hi! \n\n" . $notice . " \n\n " .<br>
"If you have any queries, please
contact us at: $CONTACT_EMAIL";<br>
mail($email, $emailSubject, $emailBody, $headers);<br>
}<br>
else { // meaning $messtype = "NOTIFY" ... sending of fax is
complete. Need to check if SUCCEEDED<br>
$tech_details = "------------------------------ \n".<br>
"DESTINATION = $dest \n".<br>
"TIMESTAMP =
$timestamp \n".<br>
"FAXOPTS_STATUSSTRING =
$status \n".<br>
"NUM_PAGES =
$numpages \n".<br>
"------------------------------ \n";<br>
<br>
<br>
echo "Sending fax notification email to: $email from
$FROM_EMAIL \n";<br>
<br>
if($status == $SUCCESS_STATUS) {<br>
$emailSubject = "Your fax to $dest was delivered
successfully";<br>
$notice = "This is an automated response to let you know
that your fax to " .<br>
"$dest sent on $timestamp was
delivered successfully. \n";<br>
} else {<br>
$emailSubject = "Your fax to $dest could not be sent";<br>
$notice = "This is an automated response to let you know
that your fax to " .<br>
"$dest sent on $timestamp could
not be delivered. \n";<br>
}<br>
<br>
$emailBody = "Hi! \n\n" . $notice . "\n\n" .
$tech_details . " \n\n " .<br>
"If you beleive there was an
error please contact: $CONTACT_EMAIL";<br>
<br>
// echo $emailSubject . "\n";<br>
// echo $emailBody . "\n";<br>
<br>
// mail<br>
mail($email, $emailSubject, $emailBody, $headers );<br>
// exec("echo $email $timestamp $emailSubject >>
/var/log/asterisk/webfax.log");<br>
// exec("echo $emailBody >>
/var/log/asterisk/webfax.log");<br>
// exec("echo -------------------------------- >>
/var/log/asterisk/webfax.log");<br>
}<br>
?><br>
<br>
<br>
<br>
<pre wrap="">
<fieldset class="mimeAttachmentHeader"></fieldset>
--
_____________________________________________________________________
-- Bandwidth and Colocation Provided by <a class="moz-txt-link-freetext" href="http://www.api-digital.com">http://www.api-digital.com</a> --
New to Asterisk? Join us for a live introductory webinar every Thurs:
<a class="moz-txt-link-freetext" href="http://www.asterisk.org/hello">http://www.asterisk.org/hello</a>
asterisk-users mailing list
To UNSUBSCRIBE or update options visit:
<a class="moz-txt-link-freetext" href="http://lists.digium.com/mailman/listinfo/asterisk-users">http://lists.digium.com/mailman/listinfo/asterisk-users</a></pre>
</blockquote>
<br>
</body>
</html>