Daniel - Asterisk
2013-Jun-19 18:03 UTC
[asterisk-users] Mailing a fax with mutt does not succeed
Hello everyone, I'm trying to send a received fax with mutt, when I try it from the Linux shel it works, but when trying with Asterisk's System command it doesn't. Successful Linux command: echo | mutt -s "New fax" earohuanca at gmail.com -a /tmp/faxes/201306191111.tif Unsuccessful Asterisk Command: same => n,System(mutt -s "New fax" elder.arohuanca at gmail.com -a ${FAXDEST}/${tempfax}.tif) I'm using Asterisk 1.8.19.0 on Debian 6.0.6, Asterisk was installed by root. Any hint will be appreciated. Elder D. Arohuanca Lima - Peru -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.digium.com/pipermail/asterisk-users/attachments/20130619/49712e32/attachment.htm>
Andre Courchesne
2013-Jun-19 18:08 UTC
[asterisk-users] Mailing a fax with mutt does not succeed
Probably Asterisk does not know where mutt is, specify it's path in your System command. On 2013-06-19, at 2:03 PM, Daniel - Asterisk <earohuanca at gmail.com> wrote:> Hello everyone, > > I'm trying to send a received fax with mutt, when I try it from the Linux shel it works, but when trying with Asterisk's System command it doesn't. > > Successful Linux command: > echo | mutt -s "New fax" earohuanca at gmail.com -a /tmp/faxes/201306191111.tif > > Unsuccessful Asterisk Command: > same => n,System(mutt -s "New fax" elder.arohuanca at gmail.com -a ${FAXDEST}/${tempfax}.tif) > > I'm using Asterisk 1.8.19.0 on Debian 6.0.6, Asterisk was installed by root. > > Any hint will be appreciated. > > Elder D. Arohuanca > Lima - Peru > -- > _____________________________________________________________________ > -- Bandwidth and Colocation Provided by http://www.api-digital.com -- > New to Asterisk? Join us for a live introductory webinar every Thurs: > http://www.asterisk.org/hello > > asterisk-users mailing list > To UNSUBSCRIBE or update options visit: > http://lists.digium.com/mailman/listinfo/asterisk-users-------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.digium.com/pipermail/asterisk-users/attachments/20130619/7f167ed9/attachment.htm>
Steve Edwards
2013-Jun-19 18:28 UTC
[asterisk-users] Mailing a fax with mutt does not succeed
On Wed, 19 Jun 2013, Daniel - Asterisk wrote:> I'm trying to send a received fax with mutt, when I try it from the > Linux shel it works, but when trying with Asterisk's System command it > doesn't. > > Successful Linux command: > echo | mutt -s "New fax" earohuanca at gmail.com -a /tmp/faxes/201306191111.tif > > Unsuccessful Asterisk Command: > same => n,System(mutt -s "New fax" elder.arohuanca at gmail.com -a ${FAXDEST}/${tempfax}.tif)1) Doesn't mutt expect the body on stdin? (Where's the 'echo' in the Asterisk command?) 2) Is Asterisk executing as root? Does the Asterisk user ID have read access to the TIFF? 3) If you use 'verbose()' instead of 'system()' does the command look like your shell command? 4) Is mutt in the Asterisk user ID's path? 5) If you redirect the output in the system() command to a file, does that yield any clues? I.e., system(foo >/tmp/clue 2>&1) -- Thanks in advance, ------------------------------------------------------------------------- Steve Edwards sedwards at sedwards.com Voice: +1-760-468-3867 PST Newline Fax: +1-760-731-3000
Ishfaq Malik
2013-Jun-20 07:49 UTC
[asterisk-users] Mailing a fax with mutt does not succeed
Hi Login as user asterisk and then try it e.g. sudo su asterisk and then try to execute the command. Last time I had this issue I had to set the shell environment for asterisk with the chsh command On Wed, 2013-06-19 at 13:03 -0500, Daniel - Asterisk wrote:> Hello everyone, > > I'm trying to send a received fax with mutt, when I try it from the > Linux shel it works, but when trying with Asterisk's System command it > doesn't. > > Successful Linux command: > echo | mutt -s "New fax" earohuanca at gmail.com > -a /tmp/faxes/201306191111.tif > > Unsuccessful Asterisk Command: > same => n,System(mutt -s "New fax" elder.arohuanca at gmail.com -a > ${FAXDEST}/${tempfax}.tif) > > I'm using Asterisk 1.8.19.0 on Debian 6.0.6, Asterisk was installed by > root. > > Any hint will be appreciated. > > Elder D. Arohuanca > Lima - Peru > > -- > _____________________________________________________________________ > -- Bandwidth and Colocation Provided by http://www.api-digital.com -- > New to Asterisk? Join us for a live introductory webinar every Thurs: > http://www.asterisk.org/hello > > asterisk-users mailing list > To UNSUBSCRIBE or update options visit: > http://lists.digium.com/mailman/listinfo/asterisk-users-- Ishfaq Malik <ish at pack-net.co.uk> Department: VOIP Support Company: Packnet Limited t: +44 (0)845 004 4994 f: +44 (0)161 660 9825 e: ish at pack-net.co.uk w: http://www.pack-net.co.uk Registered Address: PACKNET LIMITED, 2A ENTERPRISE HOUSE, LLOYD STREET NORTH, MANCHESTER SCIENCE PARK, MANCHESTER, M156SE COMPANY REG NO. 04920552
Ishfaq Malik
2013-Jun-21 07:49 UTC
[asterisk-users] Mailing a fax with mutt does not succeed
On Wed, 2013-06-19 at 13:03 -0500, Daniel - Asterisk wrote:> Hello everyone, > > I'm trying to send a received fax with mutt, when I try it from the > Linux shel it works, but when trying with Asterisk's System command it > doesn't. > > Successful Linux command: > echo | mutt -s "New fax" earohuanca at gmail.com > -a /tmp/faxes/201306191111.tif > > Unsuccessful Asterisk Command: > same => n,System(mutt -s "New fax" elder.arohuanca at gmail.com -a > ${FAXDEST}/${tempfax}.tif) > > I'm using Asterisk 1.8.19.0 on Debian 6.0.6, Asterisk was installed by > root. > > Any hint will be appreciated. > > Elder D. Arohuanca > Lima - Peru > > --I' though I sent this once already but here goes again... Have you tried changing to asterisk user and then do the same command? i.e. sudo su asterisk You may find that the asterisk user doesn't have a full shell environment and you will ahve to set one using chsh Regards Ish -- Ishfaq Malik <ish at pack-net.co.uk> Department: VOIP Support Company: Packnet Limited t: +44 (0)845 004 4994 f: +44 (0)161 660 9825 e: ish at pack-net.co.uk w: http://www.pack-net.co.uk Registered Address: PACKNET LIMITED, 2A ENTERPRISE HOUSE, LLOYD STREET NORTH, MANCHESTER SCIENCE PARK, MANCHESTER, M156SE COMPANY REG NO. 04920552
James Cloos
2013-Jun-21 22:40 UTC
[asterisk-users] Mailing a fax with mutt does not succeed
>>>>> "D" == Daniel <- Asterisk <earohuanca at gmail.com>> writes:D> I'm trying to send a received fax with mutt, when I try it from the Linux D> shel it works, but when trying with Asterisk's System command it doesn't. Sending mail from a daemon is best done by calling /usr/sbin/sendmail directly, without relying on an MUA. The default mailcmd for app_voicemail is '/usr/sbin/sendmail -t' You might also want to use the -oi flag. -JimC -- James Cloos <cloos at jhcloos.com> OpenPGP: 1024D/ED7DAEA6
Larry Moore
2013-Jun-22 02:44 UTC
[asterisk-users] Mailing a fax with mutt does not succeed
On 20/06/2013 2:03 AM, Daniel - Asterisk wrote:> Hello everyone, > I'm trying to send a received fax with mutt, when I try it from the > Linux shel it works, but when trying with Asterisk's System command it > doesn't. > Successful Linux command: > echo | mutt -s "New fax" earohuanca at gmail.com > <mailto:earohuanca at gmail.com> -a /tmp/faxes/201306191111.tif > Unsuccessful Asterisk Command: > same => n,System(mutt -s "New fax" elder.arohuanca at gmail.com > <mailto:elder.arohuanca at gmail.com> -a ${FAXDEST}/${tempfax}.tif) > I'm using Asterisk 1.8.19.0 on Debian 6.0.6, Asterisk was installed by root. > Any hint will be appreciated. > Elder D. Arohuanca > Lima - Peru > > > --Reading the responses to this thread I suspect the issue is that the Muttrc file cannot be found, I am assuming the user:group Asterisk is running as does not have a shell associated with it nor a home directory. I am using OpenBSD and the above is true for my environment. I have in my Asterisk Spool directory the folder structure /var/spool/asterisk/fax/received. This folder is read-write for the account Asterisk runs as. On my system I set it up to use macros, one to receive the fax and another to send the e-mail if one was received. The calling of the macro to send the e-mail is performed in the Hangup extension. I use extensions.ael on my system so here are the macros I set up; macro fax-receive( fax-number, header-info, sender, recipient ) { /* ${ARG1} is Receiving Station Fax Number ${ARG2} is Fax Header Information ${ARG3} is Fax Sender E-mail Address ${ARG4} is Fax Recipient E-mail Address */ NoOp(**** FAX RECEIVE ****); Set(FAXOPT(localstationid)=${LOCAL(fax-number)}); Set(FAXOPT(headerinfo)=${LOCAL(header-info)}); Set(FROMADDR=${LOCAL(sender)}); Set(TOADDR=${LOCAL(recipient)}); NoOp(**** SETTING FAXOPT ****); NoOp(FAXOPT(ecm) : ${FAXOPT(ecm)}); NoOp(FAXOPT(headerinfo) : ${FAXOPT(headerinfo)}); NoOp(FAXOPT(localstationid) : ${FAXOPT(localstationid)}); Set(RXSTART=${EPOCH}); Set(FAXRXPATH=/var/spool/asterisk/fax/received); Set(FAXRXFILE=fax-${CALLERID(number)}-${UNIQUEID}); NoOp(**** RECEIVING FAX : ${FAXRXFILE} ****); ReceiveFAX(${FAXRXPATH}/${FAXRXFILE}.tif,fd); NoOp(**** Subroutine Return ****); return; }; macro email_rxfax() { Set(CALLDURATION=$[(${EPOCH}-${RXSTART})]); System(FAXRXFILE=${FAXRXFILE} FAXRXPATH=${FAXRXPATH} FAXRXSTATUS="${FAXOPT(status)}" FAXERROR="${FAXOPT(statusstr)}" FROMADDR="${FROMADDR}" TOADDR="${TOADDR}" LOCALSTATIONID="${FAXOPT(localstationid)}" REMOTESTATIONID="${REMOTESTATIONID}" FAX PAGES=${FAXOPT(pages)} FAXBITRATE=${FAXOPT(rate)} FAXRESOLUTION=${FAXOPT(resolution)} CIDNUMBER="${CALLERID(number)}" CIDNAME ="${CALLERID(name)}" CALLDURATION=${CALLDURATION} /usr/local/sbin/afax2email); NoOp(**** STATUS : ${SYSTEMSTATUS} ****); NoOp(**** Subroutine Return ****); return; }; Note, the System() line in email_rxfax() is one long line before the NoOp(). Here is an example entry in extensions.ael; context fax-pstn1 { fax => { NoOp(Fax Received ${STRFTIME(,,%F %T %z)}); &fax-receive(+61 8 9XXXXXXX,Your Business Name,FaxMaster@<your.domain.name>,lmoore@<your.domain.name>); }; h => { if ( "X${FAXRXFILE}" != "X" ) { &email_rxfax(); } NoOp(Call/Fax Ended ${STRFTIME(,,%F %T %z)}); }; }; Here is a sample extensions.ael entry for an incioming fax. context fax-pstn1 { fax => { NoOp(Fax Received ${STRFTIME(,,%F %T %z)}); &fax-receive(+61 8 9XXXXXXX,Your Business Name,FaxMaster@<your.domain.name>,lmoore@<your.domain.name>); }; h => { if ( "X${FAXRXFILE}" != "X" ) { &email_rxfax(); } NoOp(Call/Fax Ended ${STRFTIME(,,%F %T %z)}); }; }; I created a Muttrc file in /etc/asterisk, I use msmtp for the mail progam, sendmail works but I didn't like the Envelope-From information sendmail would add hence using msmtp, because the user asterisk runs as does not have a home directory nor a shell I _had_ to use an RC file for mutt. Here is my Muttrc file. set sendmail="/usr/local/bin/msmtp" set use_from=yes set realname="Asterisk Fax Agent" set from=FaxMaster set record="" #set envelope_from=yes This is the afax2email script I use, note that mutt is called with "-F /etc/asterisk/Muttrc". #! /bin/ksh # # Script to e-mail a received fax from Asterisk # # # Environment variables imported from Asterisk # EMAIL="Asterisk Fax Agent <$FROMADDR>" export EMAIL SUBJECT TOADDR FROMADDR TIFF2PDF="/usr/local/bin/tiff2pdf" TIFFINFO="/usr/local/bin/tiffinfo" MAILER="/usr/local/bin/mutt" MAILERARGS="-F /etc/asterisk/Muttrc" FILEPATH="$FAXRXPATH/$FAXRXFILE" FAXIMAGE="$FILEPATH.tif" PDFFILE="$FILEPATH.pdf" MSGFILE="$FILEPATH.msg" DURATION=`printf "%.2d" "$CALLDURATION"` if [[ "$CALLDURATION" -ge "60" && "$CALLDURATION" -lt "3600" ]]; then S=$CALLDURATION ((mins=S/60)) ((secs=S%60)) DURATION=`printf "%.2d:%.2d\n" "$mins" "$secs"` fi if [ "$CALLDURATION" -ge "3600" ]; then S=$CALLDURATION ((hours=S/3600)) ((mins=S%3600/60)) ((secs=S%60)) DURATION=`printf "%d:%.2d:%.2d\n" "$hours" "$mins" "$secs"` fi if [[ -d "${FAXRXPATH}" && -w "${FAXRXPATH}" ]]; then if [ X"${FAXRXSTATUS}" = X"SUCCESS" ]; then SUBJECT="Facsimile received from \"$REMOTESTATIONID\"" echo "A facsimile has been received on `printf "%s" "$LOCALSTATIONID"`." > "$MSGFILE" fi if [ X"${FAXRXSTATUS}" = X"FAILED" ]; then if [ "$FAXPAGES" -ne "0" ]; then SUBJECT="Facsimile reception failed from \"$REMOTESTATIONID\"" else SUBJECT="Facsimile reception failed from telephone number \"$CIDNUMBER\"" fi echo "Problems encountered receiving facsimile on `printf "%s" "$LOCALSTATIONID"`." > "$MSGFILE" else if [[ X"${FAXRXSTATUS}" != X"SUCCESS" && X"${FAXRXSTATUS}" != X"FAILED" ]]; then SUBJECT="Facsimile reception failed from telephone number \"$CIDNUMBER\"" echo "An unknown error was encountered receiving a facsimile on `printf "%s" "$LOCALSTATIONID"`." > " $MSGFILE" fi fi echo >> "$MSGFILE" printf "%18s" "Sender: " >> "$MSGFILE"; printf "%-20s\n" "${REMOTESTATIONID}" >> "$MSGFILE" printf "%18s" "Pages: " >> "$MSGFILE"; printf "%-20s\n" "${FAXPAGES}" >> "$MSGFILE" printf "%18s" "Signal Rate: " >> "$MSGFILE"; printf "%-20s\n" "${FAXBITRATE} bit/s" >> "$MSGFILE" printf "%18s" "CallerID Number: " >> "$MSGFILE"; printf "%-20s\n" "${CIDNUMBER}" >> "$MSGFILE" printf "%18s" "CallerID Name: " >> "$MSGFILE"; printf "%-20s\n" "${CIDNAME}" >> "$MSGFILE" printf "%18s" "Call Duration: " >> "$MSGFILE"; printf "%-20s\n" "${DURATION}" >> "$MSGFILE" printf "%18s" "Status: " >> "$MSGFILE"; printf "%-20s\n" "${FAXERROR}" >> "$MSGFILE" if [ -e "${FAXIMAGE}" ]; then if (`$TIFF2PDF -o "$PDFFILE" "$FAXIMAGE"`) ; then $MAILER $MAILERARGS -s "$SUBJECT" -a "$PDFFILE" -- "$TOADDR" < "$MSGFILE" else $MAILER $MAILERARGS -s "$SUBJECT" -a "$FAXIMAGE" -- "$TOADDR" < "$MSGFILE" fi rm -f "$PDFFILE" "$MSGFILE" else $MAILER $MAILERARGS -s "$SUBJECT" "$TOADDR" < "$MSGFILE" rm -f "$MSGFILE" fi else echo "Unable to access \"${FAXRXPATH}\"" fi exit