HylaFAX The world's most advanced open source fax server

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: [hylafax-users] R: Sending PDF attachments via mail



* Enrico Ponchio <enrico.ponchio@xxxxxxxxxx> [040220 12:32]:
> 
> Anyone have a mail-to-sendfax convert that allows to send PDF attachments
> and _also_ e-mail body?

Use at your own risk.

#!/usr/bin/perl

use MIME::Parser;

my $tmp = "/tmp/mail-$$";
mkdir $tmp, 0700;

my $number = $ARGV[0];

my $parser = new MIME::Parser;
$parser->output_under($tmp);

my $entity = $parser->parse(\*STDIN);

my @parts;
my @entities = ($entity);

while ($_ = shift(@entities))
{
    my @p;
    if (@p = $_->parts)
    {
        unshift @entities, @p;
    } else
    {
        push @parts, $_;
    }
}

system("/bin/echo", "/usr/bin/sendfax",
       "-n",
       "-f", $entity->head->get('From'),
       "-d", $number,
       map ({$_->bodyhandle->path() } @parts));

system("/bin/rm", "-rf", $tmp);

____________________ HylaFAX(tm) Users Mailing List _______________________
  To subscribe/unsubscribe, click http://lists.hylafax.org/cgi-bin/lsg2.cgi
 On UNIX: mail -s unsubscribe hylafax-users-request@xxxxxxxxxxx < /dev/null
  *To learn about commercial HylaFAX(tm) support, mail sales@xxxxxxxxxxxx*




Project hosted by iFAX Solutions