Sending faxes using Perl on Windows

Here is a minimal script to send a fax using Perl on Windows:

#!/usr/bin/env perl

use strict;
use warnings;

use Win32::OLE;
$Win32::OLE::Warn = 3;

my $doc = Win32::OLE->new('FaxComEx.FaxDocument');

$doc->{Body} = 'test.txt';
$doc->{DocumentName} = "Test Program Testing Fax";
$doc->{Priority} = 1;
$doc->{Recipients}->Add('1xxxyyyzzzz', 'Fax Tester');

$doc->{Sender}{Name} = "Perl Fax Script";
$doc->{Sender}{TSID} = '1aaabbbcccc';


Of course, this assumes your computer actually has a fax modem installed. If not, the RNX-56USB looks like it would do the job.

For further information, consult Microsoft’s documentation on FaxDocument, FaxSender, and FaxServer, as well as Fax Service Extended Component Object Model (COM) API.