HylaFAX The world's
most advanced open source fax server
|
|
[
Date Prev][
Date Next][
Thread Prev][
Thread Next]
[
Date Index]
[
Thread Index]
[hylafax-users] faxrcvd-mail contribution
Hi everyone!
I'm new to the list and wud like to contribute a bit.
I've successfully installed Hylafax on our office for managing our faxes,
integrating it with Lotus Notes thru SMTP with the fax2mail gateway.
Everything works just perfect!
Maybe Hylafax become our std fax server for every branch office of our company.
In this first posting, I wud like to share with others the faxrcvd-mail perl
script I've customized to deliver both the communication log and the tiff image
(if no errors occurred) as attachments. This was a request of our users to
create a more "clean" notify msg.
Tks U all.
Ivan
#! /usr/bin/perl -w
#
# /var/spool/hylafax/bin/faxrcvd-mail
# Noel Burton-Krahn <noel@burton-krahn.com>
# revised by Ivan Daudt <ivandaudt@yahoo.com.br>
# July 12th, 2001.
#
# an extension for hylafax's faxrcvd which sends the whole fax by email
# if no errors occurred, also with the transmission log as an attachment for
# eventual debuging.
use strict;
my($file, $device, $commid, $msg, $toaddr, $fromaddr) = @ARGV;
#open(STDOUT, "|send -oi -f fax $toaddr");
my(%info, $info);
my($boundary);
$boundary=join('---',
"=Boundary=",
$$,
sprintf('%x', rand(0xffffffff)));
open(IN, "/usr/sbin/faxinfo $file|") || die("/usr/sbin/faxinfo $file:
$!");
while(<IN>) {
$info .= $_;
$info{lc($1)} = $2 if( /^\s*(\S+): (.*)$/ );
}
close(IN) || die("/usr/sbin/faxinfo: $?");
print <<EOF
From: HylaFAX Server < $fromaddr >
To: $toaddr
Subject: FAX from $info{sender} at $info{received}
Mime-Version: 1.0
Content-Type: Multipart/Mixed; Boundary=\"$boundary\"
Content-Transfer-Encoding: 7bit
This is a multi-part message in MIME format.
--$boundary
Content-Type: text/plain; charset=us-ascii
Content-Description: FAX information
Content-Transfer-Encoding: 7bit
$info
EOF
;
if( $msg ne "" ) {
print <<EOF
Document was NOT received for:
$msg
EOF
;
}
if( open(IN, "<log/c$commid") ) {
#print until EOF string is found
print <<EOF
--$boundary
Content-Type: text/plain; name="$commid.log"
Content-Description: Transmission log
Content-Transfer-Encoding:7bit
Content-Disposition: attachment; filename="$commid.log"
---- Transmission Details ----
EOF
;
print while(<IN>);
close(IN);
}
#print until EOF string is found
if ($msg eq "") {
print <<EOF
--$boundary
Content-Type: image/tiff; name="FAX from $info{sender}.tif"
Content-Description: FAX from $info{sender} at $info{received}
Content-Transfer-Encoding: base64
Content-Disposition: attachment; filename="FAX from $info{sender}.tif"
EOF
;
open(IN, "mimencode $file |") || die ("couldn't mimencode $file: $!");
print while(<IN>);
close(IN) || die("mimencode: $?");
}
print <<EOF
--$boundary--
EOF
;
____________________ HylaFAX(tm) Users Mailing List _______________________
To unsub: mail -s unsubscribe hylafax-users-request@hylafax.org < /dev/null