[Asterisk-Users] Re: *HOWTO* : using mime-construct with
outlook - send fax to email recipient
Jesse Guardiani
jesse at wingnet.net
Tue Apr 26 19:34:45 MST 2005
On Tue, 26 Apr 2005 13:50:18 -0400, Jesse Guardiani wrote:
> On Tue, 26 Apr 2005 11:50:07 -0400, Brian Dingman wrote:
>
>> Can anybody maybe help me a little here. I made the changes below...
>> but I don't think I did them exactly correct. When I get a fax now, it
>> is named:
>> _var_spool_asterisk_fax_1114530379.5.tif.pdf
>>
>> I think the problem is with the second line.
>> $p .= cont "Content-Type: $type;\n name=" .
>> token_quote($arg) . "\n"
>
> Why don't you just use the metamail package instead? Here's how
> I did it:
>
> [macro-faxreceive]
> exten => s,1,SetVar(FAXFILE=/var/spool/asterisk/fax/${UNIQUEID}.tif)
> exten => s,2,DBGet(EMAILADDR=extensionemail/${MACRO_EXTEN})
> exten => s,3,rxfax(${FAXFILE})
> exten => s,103,SetVar(EMAILADDR=jesse at wingnet.net)
> exten => s,104,Goto(3)
>
> [fax]
> exten => 2201,1,Macro(faxreceive)
> exten => 2202,1,Macro(faxreceive)
> exten => 2203,1,Macro(faxreceive)
>
> exten => h,1,system(/usr/local/sbin/mailfax ${FAXFILE} ${EMAILADDR} "${CALLERIDNUM} ${CALLERIDNAME}")
Whoops! Looks like I forgot to include this:
; Fax tone detected
exten => fax,1,Goto(fax,2201,1)
I use the above from inside an IVR, that's why I've
modularized it into a fax context with a high numbered
extension.
> NOTE: asterisk automatically jumps to the [fax] context if you are using
> faxdetect in your zapata.conf
>
> NOTE2: mailfax is a custom script I wrote. This is what it looks like:
>
> ---------------------- START mailfax script ------------------------------
> #!/bin/sh
>
> FAXFILE=$1
> RECIPIENT=$2
> FAXSENDER=$3
> FAXID=`date +%j%H%M%S`
> tempfoo="fax"
> TMPFILE=`mktemp /tmp/${tempfoo}XXXXXX`
> TMPFILE_A=`mktemp /tmp/${tempfoo}XXXXXX`.pdf
>
>
> /usr/bin/tiff2pdf -p letter "${FAXFILE}" > "${TMPFILE_A}"
> metasend -b -t "$RECIPIENT" -s "Fax from $FAXSENDER" \
> -f "${TMPFILE}" -m 'text/plain' -n \
> -m 'application/pdf;name="fax'${FAXID}'.pdf"' -f "${TMPFILE_A}" \
> -D 'PDF Fax Document'
>
> rm "${TMPFILE}"
> rm "${TMPFILE_A}"
> ---------------------- END mailfax script ------------------------------
>
> I based this config on the excellent information found at the following
> website:
> http://scottstuff.net/scott/archives/000152.html
>
> But note that I heavily modified the mailfax script from the original
> version. Why?
> 1.) The original used the Perl mime-construct script, which has a lot
> of annoying Perl dependencies.
> 2.) The original didn't send usable MIME attachments to me. Neither
> KMail or Evolution could successfully decode the attachment
> because the email contained no text/plain part.
> My script uses metasend from the metamail package, instead of
> mime-construct, and it adds an empty text/plain section at the beginning
> of the email so that KMail and Evolution and probably other mail clients
> can decode the attachment properly. The trade off is that it has to use
> temporary files. Uck. :)
>
> Also, you'll probably have to change some of the paths for things like
> tiff2pdf and metasend.
>
> HTH!
>
>
>
>
>
>> Thanks
>>
>> On 2/7/05, Asterisk <asterisk at dotr.com> wrote:
>>> We've managed to setup spandsp to receive faxes and email them to the
>>> appropriate person.
>>>
>>> We did all of our testing using Thunderbird, and the attached pdf files
>>> worked very well. However, when we went "live", some people complained
>>> that the attachments in outlook were named <<subject>>.dat instead (for
>>> example) of 123456.pdf
>>>
>>> Having looked into the mime-construct script, we noticed a subtle
>>> difference between working Outlook attachments and Thunderbird. The
>>> differences are shown below in case anyone is interested.
>>>
>>> left is the original mime-construct, right is our modified version
>>>
>>> 332c332
>>> < $part_header .= "Content-Disposition: attachment; filename="
>>> ---
>>> > $part_header .= "Content-Disposition: inline; filename="
>>> 405c405
>>> < $p .= cont "Content-Type: $type\n"
>>> ---
>>> > $p .= cont "Content-Type: $type;\n name=" .
>>> token_quote($arg) . "\n"
>>>
>>> Outlook now names the attachment correctly, and Thunderbird also seems
>>> to work just as well with the changes.
>>>
>>> Hope someone finds this useful.
>>>
>>> Julian.
>>>
>>> _______________________________________________
>>> Asterisk-Users mailing list
>>> Asterisk-Users at lists.digium.com
>>> http://lists.digium.com/mailman/listinfo/asterisk-users
>>> To UNSUBSCRIBE or update options visit:
>>> http://lists.digium.com/mailman/listinfo/asterisk-users
>>>
>> _______________________________________________
>> Asterisk-Users mailing list
>> Asterisk-Users at lists.digium.com
>> http://lists.digium.com/mailman/listinfo/asterisk-users
>> To UNSUBSCRIBE or update options visit:
>> http://lists.digium.com/mailman/listinfo/asterisk-users
--
Jesse Guardiani, Systems Administrator
WingNET Internet Services,
P.O. Box 2605 // Cleveland, TN 37320-2605
423-559-LINK (v) 423-559-5145 (f)
http://www.wingnet.net
More information about the asterisk-users
mailing list