SYNOPSIS

     use Fax::Hylafax::Client qw(sendfax);

     my $fax = sendfax(
          dialstring    => '5555555555',
          docfile       => '/usr/home/test/document.ps',
     );

DESCRIPTION

This is a simple Perl client for HylaFAX fax server (www.hylafax.org). It communicates with the server directly through FTP-like protocol and thus does not require any HylaFAX software components to be installed on the client machine.

MAIN METHODS AND ATTRIBUTES

sendfax

This method sends a fax job to the server. Returns \*(L"Client::Queued\*(R" object. Takes a hash of the following attributes:

host

Hostname of the server. Defaults to \*(L"localhost\*(R". [\s-1OPTIONAL\s0]

port

Connection port of the server. Defaults to \*(L"4559\*(R". [\s-1OPTIONAL\s0]

user

Username of the client. Defaults to \*(L"anonymous\*(R". [\s-1MAY\s0 \s-1BE\s0 \s-1REQUIRED\s0]

password

Password of the client. Defaults to \*(L"anonymous\*(R". [\s-1MAY\s0 \s-1BE\s0 \s-1REQUIRED\s0]

dialstring

Destination string (number) to dial. [\s-1REQUIRED\s0]

docfile

Full pathname of the document file. This attribute takes a single filename (scalar) or a reference to an array of filenames. Document files must be in one of the native HylaFAX formats, i.e. Plain Text, PostScript, \s-1TIFF\s0 Class F, or \s-1PDF\s0. [\s-1REQUIRED\s0 unless you use \*(L"poll\*(R" option]

coverfile

Full pathname of the cover page file. All notes about \*(L"docfile\*(R" apply, except it only takes one filename as scalar. [\s-1OPTIONAL\s0]

notifyaddr

E-mail address of the person to be notified about the status of the job. Defaults to \*(L"user@hostname\*(R". [\s-1OPTIONAL\s0]

notify

Controls the email notification messages from the server. Possible values: \*(L"none\*(R" - notify if error only, \*(L"done\*(R" - notify when done, \*(L"requeue\*(R" - notify if job is re-queued, \*(L"done+requeue\*(R". Defaults to \*(L"none\*(R". [\s-1OPTIONAL\s0]

passive

If set to \*(L"1\*(R" connects to server in \s-1PASSIVE\s0 mode. Defaults to \*(L"0\*(R". [\s-1OPTIONAL\s0]

sendtime

Time when the fax should be sent. Possible values: \*(L"now\*(R" or date in format \*(L"\s-1YYYYMMDDHHMM\s0\*(R". It looks like this value must be in \s-1GMT\s0 time zone. Defaults to \*(L"now\*(R". [\s-1OPTIONAL\s0]

lasttime

Kill the job if not successfully sent after this much time. Format \*(L"\s-1DDHHSS\s0\*(R". Defaults to \*(L"000259\*(R" (3 hours). [\s-1OPTIONAL\s0]

maxdials

The maximum number of times to dial the phone. Defaults to \*(L"12\*(R". [\s-1OPTIONAL\s0]

maxtries

The maximum number of times to retry sending a job once connection is established. Defaults to \*(L"3\*(R". [\s-1OPTIONAL\s0]

pagewidth

Set the transmitted page width in millimeters. Defaults to \*(L"216\*(R" (Letter size). [\s-1OPTIONAL\s0]

pagelength

Set the transmitted page length in millimeters. Defaults to \*(L"279\*(R" (Letter size). [\s-1OPTIONAL\s0]

vres

Set the vertical resolution in lines/inch to use when transmitting facsimile. High resolution equals to \*(L"196\*(R", low resolution equals to \*(L"98\*(R". Defaults to \*(L"196\*(R". [\s-1OPTIONAL\s0]

chopthreshold

The amount of white space, in inches, that must be present at the bottom of a page before HylaFAX will attempt to truncate the page transmission. Defaults to \*(L"3\*(R". [\s-1OPTIONAL\s0]

schedpri

The scheduling priority to assign to the job. Defaults to \*(L"127\*(R" (Normal). [\s-1OPTIONAL\s0]

poll

Try to poll a fax from remote machine. Value can be an empty string or \*(L"selector [passwd]\*(R". [\s-1OPTIONAL\s0]

sendpage

Sends \s-1SNPP\s0 page job to the server. Returns \*(L"Client::Queued\*(R" object. Takes a hash of the following attributes:

host

Same as in \*(L"sendfax\*(R".

port

Connection port of the server. Defaults to \*(L"444\*(R". [\s-1OPTIONAL\s0]

user

Same as in \*(L"sendfax\*(R".

password

Same as in \*(L"sendfax\*(R".

pin

Pager Identification Number as defined in \*(L"pagermap\*(R" file on the server. [\s-1REQUIRED\s0]

message

Text message to be sent (alfa-numeric pagers only). [\s-1OPTIONAL\s0]

notifyaddr

Same as in \*(L"sendfax\*(R".

notify

Same as in \*(L"sendfax\*(R".

passive

Same as in \*(L"sendfax\*(R".

maxdials

Same as in \*(L"sendfax\*(R".

maxtries

Same as in \*(L"sendfax\*(R".

level

Priority level to assign to the job. Values can be \*(L"0-7\*(R" (0 being the highest). Defaults to \*(L"1\*(R" (Normal). [\s-1OPTIONAL\s0]

faxinfo

Request the status of a particular job. Returns \*(L"Client::Instant\*(R" object. Can take only the number of the job as an attribute or a hash of the following attributes:

host

Same as in \*(L"sendfax\*(R".

port

Same as in \*(L"sendfax\*(R".

user

Same as in \*(L"sendfax\*(R".

password

Same as in \*(L"sendfax\*(R".

jobid

\s-1ID\s0 of the job. [\s-1REQUIRED\s0]

passive

Same as in \*(L"sendfax\*(R".

faxrm

Remove job from the server (kill it). Returns \*(L"Client::Instant\*(R" object. Behaves like and has the same attributes as \*(L"faxinfo\*(R".

faxstat

Request statistics from the server. Returns \*(L"Client::Instant\*(R" object. Takes a hash of the following attributes:

host

Same as in \*(L"sendfax\*(R".

port

Same as in \*(L"sendfax\*(R".

user

Same as in \*(L"sendfax\*(R".

password

Same as in \*(L"sendfax\*(R".

passive

Same as in \*(L"sendfax\*(R".

info

If set to \*(L"1\*(R" displays additional status information for the server. This status typically has information such as the HylaFAX version, the physical location of the server machine, and an administrative contact for the server. Defaults to \*(L"0\*(R". [\s-1OPTIONAL\s0]

files

If set to \*(L"1\*(R" displays the status of document files located in the docq directory on the server machine. The \*(L"filefmt\*(R" attribute defines the content and format of information reported with this option. Defaults to \*(L"0\*(R". [\s-1OPTIONAL\s0]

queue

If set to \*(L"1\*(R" displays the status of jobs in the send queue on the server machine. The \*(L"jobjmt\*(R" attribute defines the content and format of information reported with this option. Defaults to \*(L"0\*(R". [\s-1OPTIONAL\s0]

done

If set to \*(L"1\*(R" displays the status of all jobs that have completed; i.e. those jobs located in the doneq directory on the server machine. The \*(L"jobfmt\*(R" attribute defines the content and format of information reported with this option. Defaults to \*(L"0\*(R". [\s-1OPTIONAL\s0]

received

If set to \*(L"1\*(R" displays the receive queue status. The \*(L"rcvfmt\*(R" attribute defines the content and format of information reported with this option. Defaults to \*(L"0\*(R". [\s-1OPTIONAL\s0]

filefmt

The format string to use when returning file status information. See \*(L"faxstat\*(R" man pages for details. [\s-1OPTIONAL\s0]

jobfmt

The format string to use when returning job status information. See \*(L"faxstat\*(R" man pages for details. [\s-1OPTIONAL\s0]

rcvfmt

The format string to use when returning status information about received jobs. See \*(L"faxstat\*(R" man pages for details. [\s-1OPTIONAL\s0]

METHODS AND ATTRIBUTES OF ALL Client::* OBJECTS

success

Returns true if the task was accepted. This only means the task request was successfully processed by the server. This does not always mean the task itself was successfully completed. Use \*(L"faxinfo\*(R" to check for that.

trace

Returns responses from the last communication with the server. Userful for debugging.

METHODS AND ATTRIBUTES OF Client::Queued OBJECTS ONLY

faxinfo

Returns the status of the job at this particular moment.

faxrm

Kills the job.

jobid

Returns the \s-1ID\s0 assigned to the job by the server.

METHODS AND ATTRIBUTES OF Client::Instant OBJECTS ONLY

content

Returns content returned by the server.

GLOBAL VARIABLES

Specifies hostname of the server. Used in place of \*(L"host\*(R" attribute. Specifies connection port of the server. Used in place of \*(L"port\*(R" attribute. Username of the client. Used in place of \*(L"user\*(R" attribute. Password of the client. Used in place of \*(L"password\*(R" attribute. Specifies if \s-1PASSIVE\s0 connections should be used. Used in place of \*(L"passive\*(R" attribute. E-mail address where server notifications will be sent. Used in place of \*(L"notifyaddr\*(R" attribute.

EXAMPLES

Send a fax

use Fax::Hylafax::Client qw(sendfax);

my $fax = sendfax( host => 'remote.host.name', dialstring => '14151234567', docfile => '/usr/home/test/document.ps', coverfile => '/usr/home/test/cover.ps', notifyaddr => '[email protected]', );

if ($fax->success) { print "We are OK"; } else { print $fax->trace; }

Misc. examples

use Fax::Hylafax::Client qw(sendfax sendpage faxstat faxinfo faxrm);

$Fax::Hylafax::Client::Host = 'remote.server.hostname'; $Fax::Hylafax::Client::User = 'faxuser'; $Fax::Hylafax::Client::Password = '*password*'; $Fax::Hylafax::Client::NotifyAddr = '[email protected]';

my $fax = sendfax( dialstring => '14151234567', docfile => [ '/usr/home/test/document1.ps', '/usr/home/test/document2.ps', ], );

my $task_succeded = $fax->success ? "YES" : "NO"; my $server_responses = $fax->trace; my $job_id = $fax->jobid; my $current_job_status = $fax->faxinfo;

my $server_stats = faxstat( info => 1, active => 1 )->content; if (faxinfo($job_id)->content ne 'DONE') { print "We're not done yet";

$fax->faxrm;

# or

faxrm($job_id);

# or

my $task = faxrm( host => 'remote.server.hostname', user => 'faxuser', password => '*password*', jobid => $job_id, ); print $task->success ? "We killed it!" : "Server didn't like it: " . $task->trace; }

my $other_server_task = faxstats( host => 'other.server.host', user => 'bob', password => 'whatever' ); if ($other_server_task->success) { print $other_server_task->content; } else { print "Doh! We failed to get stats from the server: ", $other_server_task->trace; }

my $page = sendpage( pin => 'bob', message => 'Time to wake up', ); my $task_succeded = $page->success ? "YES" : "NO";

AUTHOR

COPYRIGHT

Copyright (c) 2003,2006 Alex Rak. All rights reserved.

This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.

RELATED TO Fax::Hylafax::Client…

HylaFAX man pages <http://www.hylafax.org/>