mail2fax sendet nicht..

2bbionic

Neuer User
Mitglied seit
5 Sep 2005
Beiträge
34
Punkte für Reaktionen
0
Punkte
0
Hallo,

ich habe mein Asterisk mit den agx-addons ausgestattet, was eigentlich reibungslos funktioniert hat. Zur Zeit habe ich noch zwei Probleme beim Empfang, wovon ich aktuell eines hier ansprechen und beheben will:

Nachdem ein Fax eingetroffen ist, sollte es ja eigentlich von dem Skript fax2mail verarbeitet und versendet werden - genau das macht es aber nicht. Es kommt keine Fehlermeldung und auch sonst nix. Das Fax wird empfangen, das Log sagt auch OK und ich sehe auch eine Datei, aber sonst passiert gar nix. Rufe ich das Script manuell auf, funktioniert alles reibungslos. Vielleicht könnte sich ja jemand die Mühe machen und mir zeigen, wo mein Fehler liegt. Anbei die entsprechenden Dateien:

Asterisk core set verbose 50:
Code:
Connected to Asterisk 1.4.17 currently running on aurea (pid = 4507)
aurea*CLI> core set verbose 50
Verbosity was 0 and is now 50
    -- ast_get_srv: SRV lookup for '_sip._udp.sipgate.de' mapped to host sipgate.de, port 5060
P[ 1] I IND :NEW_CHANNEL oad:xxxxx dad:yyyyyy pid:21 state:none
P[ 1]  --> channel:1 mode:TE cause:16 ocause:16 rad: cad:
P[ 1]  --> info_dad: onumplan:2 dnumplan:4 rnumplan:  cpnnumplan:0
P[ 1] Chan not existing at the moment bc->l3id:20011 bc:0x81bb8a4 event:NEW_CHANNEL port:1 channel:1
P[ 1] NO USERUESRINFO
P[ 1]  --> TRANSPARENT Mode
P[ 1] I IND :SETUP oad:xxxxx dad:yyyyyy pid:21 state:none
P[ 1]  --> channel:1 mode:TE cause:16 ocause:16 rad: cad:
P[ 1]  --> info_dad: onumplan:2 dnumplan:4 rnumplan:  cpnnumplan:0
P[ 1]  --> Bearer: Audio 3.1k
P[ 1]  --> Codec: Alaw
P[ 1]  --> Bearer: Audio 3.1k
P[ 1]  --> Codec: Alaw
P[ 0]  --> * NEW CHANNEL dad:yyyyyy oad:xxxxx
P[ 1] read_config: Getting Config
P[ 1]  --> CTON: Unknown
P[ 1]  --> PRES: Restricted (0)
P[ 1]  --> SCREEN: Unscreened (0)
P[ 1] I SEND:PROCEEDING oad:0xxxxx dad:yyyyyy pid:21
P[ 1]  --> channel:1 mode:TE cause:16 ocause:16 rad: cad:
P[ 1]  --> info_dad: onumplan:2 dnumplan:4 rnumplan:  cpnnumplan:0
    -- Executing [yyyyyy@default:1] Dial("mISDN/1-u30", "SIP/84404@sipgate-de-out|45|Ttr)") in new stack
    -- Called 84404@sipgate-de-out
P[ 1] * IND :   ringing pid:21
P[ 1]  --> * IND :      ringing pid:21
P[ 1] I SEND:ALERTING oad:0xxxxx dad:yyyyyy pid:21
P[ 1]  --> channel:1 mode:TE cause:16 ocause:16 rad: cad:
P[ 1]  --> info_dad: onumplan:2 dnumplan:4 rnumplan:  cpnnumplan:0
P[ 1]  --> incoming_early_audio off
    -- SIP/sipgate-de-out-08231758 is circuit-busy
  == Everyone is busy/congested at this time (1:0/1/0)
P[ 1]  --> * IND :      -1! (stop indication) pid:21
    -- Executing [yyyyyy@default:2] misdn_set_opt("mISDN/1-u30", "n:!e:jt0") in new stack
P[ 1] SETOPT: No DSP
P[ 1] SETOPT: EchoCancel
P[ 1]  --> disabled
P[ 1] SETOPT: jitter
P[ 1]  --> upper_threshold:0
P[ 1] config_jb: We've got a Jitterbuffer Already on this port.
    -- Executing [yyyyyy@default:3] Set("mISDN/1-u30", "CALLEDFAX=yyyyyy") in new stack
    -- Executing [yyyyyy@default:4] Macro("mISDN/1-u30", "faxempfang") in new stack
    -- Executing [s@macro-faxempfang:1] Set("mISDN/1-u30", "SCRIPTFILE=/var/lib/asterisk/scripts/fax2mail") in new stack
    -- Executing [s@macro-faxempfang:2] Set("mISDN/1-u30", "FAXFILE=/var/spool/asterisk/fax/1205153171.39.tif") in new stack
    -- Executing [s@macro-faxempfang:3] Set("mISDN/1-u30", "[EMAIL="[email protected]"][email protected][/EMAIL]") in new stack
    -- Executing [yyyyyy@default:5] RxFAX("mISDN/1-u30", "/var/spool/asterisk/fax/1205153171.39.tif") in new stack
P[ 1] * ANSWER:
P[ 1]  --> empty cad using dad
P[ 1] I SEND:CONNECT oad:0xxxxx dad:yyyyyy pid:21
P[ 1]  --> channel:1 mode:TE cause:16 ocause:16 rad: cad:yyyyyy
P[ 1]  --> info_dad: onumplan:2 dnumplan:4 rnumplan:  cpnnumplan:0
P[ 1] I IND :CONNECT_ACKNOWLEDGE  oad:0xxxxx dad:yyyyyy pid:21 state:CONNECTED
P[ 1]  --> channel:1 mode:TE cause:16 ocause:16 rad: cad:yyyyyy
P[ 1]  --> info_dad: onumplan:2 dnumplan:4 rnumplan:  cpnnumplan:0
extensions.conf
Code:
[macro-faxempfang]
exten => s,1,Set(SCRIPTFILE=/var/lib/asterisk/scripts/fax2mail)
exten => s,n,Set(FAXFILE=/var/spool/asterisk/fax/${UNIQUEID}.tif)
exten => s,n,Set([EMAIL="[email protected]"][email protected][/EMAIL])
[fax_in]
exten => 08154711,1,Wait(3)
exten => 08154711,n,misdn_set_opt(n:!e:jt0)
exten => 08154711,n,Set(CALLEDFAX=${EXTEN})
exten => 08154711,n,Macro(faxempfang)
exten => 08154711,n,RxFAX(${FAXFILE})
exten => 08154711,n,System("${SCRIPTFILE}" --cid-number "${CALLERIDNUM}" --dest-email "${MAILADDR}" -f "${FAXFILE}")
exten => 08154711,n,Hangup
fax_in wird in [default] inkludiert.

Code:
ls -alh /var/lib/asterisk/scripts/
insgesamt 28K
drwxr-xr-x  2 root root  36 10. Mär 13:00 .
drwxr-xr-x 10 root root 126  9. Mär 20:07 ..
-rwxrwxrwx  1 root root 13K 10. Mär 13:00 fax2mail
-rwxrwxrwx  1 root root 11K  8. Mär 14:15 mail2fax

Code:
ps auwx|grep asterisk
root      4507  0.0  2.6  35928  8764 ?        Ssl  Mar09   0:00 asterisk
Code:
ls -alh /var/spool/asterisk/fax/
insgesamt 952K
drwxr-xr-x  2 root root 4,0K 10. Mär 13:14 .
drwxr-xr-x 10 root root  111 13. Feb 15:57 ..
..
-rw-r--r--  1 root root    8 10. Mär 13:08 1205150896.33.tif
-rw-r--r--  1 root root    8 10. Mär 13:11 1205151077.35.tif
-rw-r--r--  1 root root    8 10. Mär 13:14 1205151244.37.tif
Und um dieses Script dreh's sichs:

Code:
#!/bin/bash
#=========================================================================|
#                                                                         |
# File: fax2mail                                                          |
# Type: BASH script                                                       |
# Summary: fax to E-Mail helper application for asterisk PBX              |
# Description: fax2mail is a helper application which sits between        |
#   asterisk and a MTA.  Is is designed to be called by asterisk upon the |
#   receipt of a new fax.  It will forward the received fax to the email  |
#   address of choice, and will convert the file the one of several       |
#   formats.                                                              |
#                                                                         |
#=========================================================================|
#                                                                         |
# Usage:                                                                  |
#   fax2mail allows these parameters from asterisk as follows:            |
#     -p = To attach in pdf format (default)                              |
#     -e = To attach in eps format                                        |
#     -t = To attach in tif format                                        |
#     -f = absolute path to file w/out .tif extension                     |
#     --cid-name <CID Name> = Set CID Name of caller to <CID Name>        |
#     --cid-number <CID Number> = Set CID Number of caller to <CID Number>|
#     --dest-exten <Exten Called> = Used to look up destination info      |
#         from voicemail.conf.                                            |
#     --dest-email <Destination Email> = Used to send teh email to.       |
#         optional if --dest-exten is provided so that the email address  |
#         can be looked up in voicemail.conf                              |
#                                                                         |
#=========================================================================|
#                                                                         |
# Examples:                                                               |
#   fax2mail -f /absolute/path/file                                       |
#     file.tif in /absolute/path/ would be coverted to a pdf and sent to  |
#     the email address specified in the "DEFAULTTO" global variable      |
#   fax2mail -f /absolute/path/file --dest-exten 100                      |
#     file.tif in /absolute/path/ would be converted to a pdf and sent to |
#     the email address associated with the exten 100 in voicemail.conf   |
#   fax2mail -t -f /absolute/path/file --dest-email [EMAIL="[email protected]"][email protected][/EMAIL]       |
#     file.tif in /absolute/path/ would be emailed in tif format to       |
#     [EMAIL="[email protected]"][email protected][/EMAIL]                                                     |
#                                                                         |
#=========================================================================|
#                                                                         |
#  Astrerisk config:                                                      |
#    [default]                                                            |
#    ...Unimportant stuff removed for this...                             |
#    ;Detected fax call                                                   |
#    exten => fax,1,Goto(fax,s,1)                                         |
#                                                                         |
#    [fax]                                                                |
#    exten => s,1,Macro(recvfax)                                          |
#    exten => h,1,System('/usr/bin/fax2mail --cid-number "${CALLERIDNUM}" |
#             --cid-name "${CALLERIDNAME}" --dest-exten "${INIT_EXTEN}"   |
#             -f "${FAXFILE}"')                                           |
#    NOTE: INIT_EXTEN has to be set with something similar to...          |
#          exten => s,n,Set(INIT_EXTEN=${EXTEN})                          |
#                                                                         |
#  [macro-recvfax]                                                        |
#    ;                                                                    |
#    ;  Receive incoming fax macro:                                       |
#    ;                                                                    |
#    exten => s,1,Set(FAXFILE=/var/spool/asterisk/fax/${STRFTIME(${EPOCH} |
#              ,,%Y%m%M%S)}-${CALLERIDNUM}-${INIT_EXTEN})                  |
#    exten => s,2,rxfax(${FAXFILE}.tif)                                   |
#                                                                         |
#=========================================================================|
#                                                                         |
# Dependencies:                                                           |
#   This application requires asterisk, ast_fax, app_rxfax, tifflib       |
#   mime-construct                                                        |
#                                                                         |
#=========================================================================|
#                                                                         |
# Author:                                                                 |
#   Designed and written by Michelle Dupuis on October 7, 2005            |
#   Michelle can be reached at support@ocgca                              |
#   This script and other related tools are available for download        |
#   at [URL="http://www.generationd.com"]www.generationd.com[/URL]                                                |
#                                                                         |
#=========================================================================|
#                                                                         |
# DATE         VER  AUTHOR        DESCRIPTION                             |
# Oct 7 2005   1.0  M Dupuis      Original coding                         |
# Oct 9 2005   1.8  M Dupuis      Better parameter & email checking       |
# Oct 23 2005  1.9  M Dupuis      Syntax error fixes, hand ! in ID name   |
# Oct 25 2005  2.0  M Dupuis      Improved page count mechanism           |
# Nov 23 2006  2.1  J Puckett     Generalized the script & pulled vars    |
#                                 from voicemail.conf                     |
# Nov 29 2006  2.2  J Puckett     Made grep use regex to find exten and   |
#                                 modified documentation                  |
#                                                                         |
#=========================================================================|
VERSION="fax2mail v2.1.1"
LOGFILE="/var/log/asterisk/faxlog"  #Set to /dev/null to disable logging
DATETIME=$(date +"%A, %B %d %Y, at %I:%M %p")
FROMEMAIL="Asterisk PBX <[EMAIL="[email protected]"][email protected][/EMAIL]>"
DEFAULTTO="[EMAIL="[email protected]"][email protected][/EMAIL]"
echo >>$LOGFILE
echo $VERSION >>$LOGFILE
echo "  Triggered on $DATETIME">>$LOGFILE
echo "  Called with $*">>$LOGFILE
if [ ${#} -le 1 ]; then
  echo "Usage: $CMD_SCRIPT [-p | -e | -t] -f File [--cid-name <CID Name>] [--cid-number <CID Number>] [--dest-exten <Extension Called>] [--dest-name <Destination Name>] [--dest-email <Destination Email>]"
  echo "  No parameters were given.">>$LOGFILE
  exit 1;
fi
CID_NAME=""
CID_NUMBER=""
DEST_NAME=""
DEST_EMAIL=""
DEST_EXTEN=""
FILE=""
FORMAT="pdf"
while [ ${#} -gt 0 ]; do
  case "${1}" in
    "--cid-name" )
      CID_NAME=${2}
      shift
      ;;
    "--cid-number" )
      CID_NUMBER=${2}
      shift
      ;;
    "--dest-name" )
      DEST_NAME=${2}
      shift
      ;;
    "--dest-email" )
      DEST_EMAIL=${2}
      shift
      ;;
    "--dest-exten" )
      DEST_EXTEN=${2}
      shift
      ;;
    "--file" | "-f" )
      FILE=${2}
      shift
      ;;
    "-e" )
      FORMAT="eps"
      ;;
    "-t" )
      FORMAT="tif"
      ;;
    "-p" )
      FORMAT="pdf"
      ;;
  esac
  shift
done
if [ "$FILE" = "" ]; then
  echo "Error: A file is required"
  echo "  No file was given.">>$LOGFILE
  exit 1;
fi
echo "  CallerID number of fax sender = $CID_NUMBER">>$LOGFILE
echo "  CallerID name of fax sender = $CID_NAME">>$LOGFILE
echo "  Fax number called = $DEST_EXTEN">>$LOGFILE
echo "  Destination name = $DEST_NAME">>$LOGFILE
echo "  Destination email address = $DEST_EMAIL">>$LOGFILE
echo "  Fax file name (without .tif extension) = $FILE">>$LOGFILE
echo "  Attachment format conversion = $FORMAT">>$LOGFILE
# Correct for missing info
if [ "$CID_NUMBER" = "" ] ; then
  CID_NUMBER="<unknown number>"
  echo "    Set CallerID number of fax sender to $CID_NUMBER">>$LOGFILE
fi
# Must surround in quotes in case name is preceded by a !
if [ "$CID_NAME" = "" ] ; then
  CID_NAME="<unknown name>"
  echo "    Set CallerID name of fax sender to $CID_NAME">>$LOGFILE
fi
if [ "$DEST_EXTEN" = "" ] ; then
  DEST_EXTEN="<unknown number>"
  echo "    Set Fax number called to $DEST_EXTEN">>$LOGFILE
fi
# Get destination name if empty
if [ "$DEST_NAME" = "" ] ; then
  DEST_NAME=`egrep "^$DEST_EXTEN\s*=>\s*" /etc/asterisk/voicemail.conf | cut -d, -f2`
  echo "    Set Destination name to $DEST_NAME">>$LOGFILE
fi
# Get destination email if empty
if [ "$DEST_EMAIL" = "" ] ; then
  DEST_EMAIL=`grep "^$DEST_EXTEN\s*=>\s*" /etc/asterisk/voicemail.conf | cut -d, -f3-`
  if [ "$DEST_EMAIL" = "" ] ; then
    DEST_EMAIL=$DEFAULTTO
  fi
  echo "    Set Destination email address to $DEST_EMAIL">>$LOGFILE
fi
SOURCEFILE=$FILE
DESTFILE=$FILE.$FORMAT
INFOFILE=$FILE.txt
if [ -e $SOURCEFILE ]
  then
  echo "  Fax file $SOURCEFILE found.">>$LOGFILE
  # Read data from TIFF file
  PAGES=$(tiffinfo $SOURCEFILE | grep "Page" | cut -d " " -f 1)
  DT=$(tiffinfo $SOURCEFILE | grep "Date")
  DTFAX=${DT#*:}
  COUNT=${PAGES#*-}
  if [ -z $COUNT ]
  then
    # If didn't find a page count, use the number of occurrences of "spandsp"
    COUNT=$(grep -c "spandsp" $SOURCEFILE)
    if [ -z $COUNT ]
    then
      COUNT="<unknown>"
    fi
  fi
# Do any conversions requested
case "$FORMAT" in
  # Check if PDF conversion required
  "pdf" )
    tiff2pdf -f -p letter $SOURCEFILE > $DESTFILE
    #I like to keep around for a few days & use tmpwatch to clean up
#    rm -f $SOURCEFILE
    echo "  Converted $SOURCEFILE to $DESTFILE.">>$LOGFILE
    ;;
  # Check if EPS conversion required
  "eps" )
    tiff2ps -2eaz -w 8.3 -h 11.7 $SOURCEFILE > $DESTFILE
#    rm -f $SOURCEFILE
    echo "  Converted $SOURCEFILE to $DESTFILE.">>$LOGFILE
    ;;
  # Default to leave as tif
  *)
    echo "  No conversion of $SOURCEFILE required.">>$LOGFILE
    ;;
esac
echo -n >$INFOFILE
echo "Dear $DEST_NAME,">>$INFOFILE
echo >>$INFOFILE
echo "You have just received a $COUNT page fax from $CID_NAME <$CID_NUMBER>, at phone number $DEST_EXTEN, on $DATETIME.  The original fax document is attached in $FORMAT format.">>$INFOFILE
echo >>$INFOFILE
echo >>$INFOFILE
echo >>$INFOFILE
cat $DESTFILE | mime-construct --subpart --attachment fax.$FORMAT --type application/$FORMAT --file - >$FILE.part1
cat $INFOFILE | mime-construct --header "From: $FROMEMAIL" --to $DEST_EMAIL --subject "[PBX]: New fax from $CID_NAME <$CID_NUMBER>" --subpart-file $FILE.part1 --file -
echo "  E-mailed file to $DEST_EMAIL">>$LOGFILE
# Delete the destination file
echo "  Removing destination file $DESTFILE">>$LOGFILE
rm -f $DESTFILE
# Exit with OK status code
RETVAL=0
# Else tif file is missing
else
echo "  Fax file $SOURCEFILE not found.">>$LOGFILE
echo -n > $INFOFILE
echo "Dear $DEST_NAME,">>$INFOFILE
echo >>$INFOFILE
echo "You have just received a fax attempt from $CID_NAME <$CID_NUMBER>, at phone number $DEST_EXTEN, on $DATETIME.  There was a problem receiving the fax.">>$INFOFILE
echo >>$INFOFILE
echo >>$INFOFILE
cat $INFOFILE | mime-construct --header "From: $FROMEMAIL" --to $DEST_EMAIL --subject "[PBX]: Failed fax attempt from $CID_NAME <$CID_NUMBER>" --file -
echo "  "E-mailed warning to $DEST_EMAIL >>$LOGFILE
RETVAL=1
fi
# Delete the temporary message file
rm -f $FILE.part1
rm -f $INFOFILE
echo >>$LOGFILE
# exit with failure code
exit $RETVAL

Wäre super, wenn mir jemand einen Tipp geben könnte.

Grüße,

2bbionic
 
Funktionierts denn wenn Du fax2mail von Hand aufrufst?
 
Ja, dann funktioniert es reibungslos, das ist ja das komische. Sieht so aus, als würde der * das Script nicht aufrufen...?
 
Kostenlos!

Statistik des Forums

Themen
248,900
Beiträge
2,304,495
Mitglieder
378,599
Neuestes Mitglied
Bone1104