#/**************** Settings begin **************/ my $username = ''; # Enter your Interfax username here my $password = ''; # Enter your Interfax password here # Semicolon-delimited list of destination fax numbers my $faxNumbers = '+12077301111;+492077301222;+442077301333'; # Optional semicolon-delimited list of recipient names; one per fax number my $contacts = 'Rachel Burns;Albie Eins;Max Planck'; # Files to fax. Files are assumed to be in the local directory my @files = ('sample.txt', 'sample.html'); my $postponeTime = '2001-12-31T00:00:00-00:00'; my $retries = '3'; my $csid = 'AA CSID'; my $pageHeader = 'To: {To} From: {From} Pages: {TotalPages}'; my $subject = 'Anything goes'; my $replyEmail = ''; my $pageSize = 'A4'; my $pageOrientation = 'Portrait'; my $highResolution = 0; my $fineRendering = 1; my $NS = 'http://www.interfax.cc'; #/**************** Settings end ****************/ my $fileTypes = ''; my $fileData = ''; my $fileSizes = ''; my ($file, $datafile); for(my $i = 0; $i < @files; $i++) { $file = ""; # Read file as binary in 1K blocks open FILE, $files[$i] or die $!; while (read FILE, $datafile, 1024 != 0) { $file .= $datafile; } close FILE; $fileData .= $file; # Get the filesize $fileSizes .= ( -s $files[$i] ) . ';'; # Get the extension $fileTypes .= (split(/\./, $files[$i]))[1] . ';'; } chop( $fileSizes ); # remove the last ';' chop( $fileTypes ); # remove the last ';' $fileData = encode_base64( $fileData ); my $client = SOAP::Lite ->uri($NS) ->on_action( sub { join '/', $NS, $_[1] } ) ->proxy('https://ws.interfax.net/dfs.asmx?wsdl'); my $result = $client ->call(SOAP::Data->name('SendfaxEx_2')->attr({xmlns => $NS}) => SOAP::Data->name('Username')->value($username)->type(''), SOAP::Data->name('Password')->value($password)->type(''), SOAP::Data->name('FaxNumbers')->value($faxNumbers)->type(''), SOAP::Data->name('Contacts')->value($contacts)->type(''), SOAP::Data->name('FilesData')->value($fileData)->type(''), SOAP::Data->name('FileTypes')->value($fileTypes)->type(''), SOAP::Data->name('FileSizes')->value($fileSizes)->type(''), SOAP::Data->name('Postpone')->value($postponeTime)->type(''), SOAP::Data->name('RetriesToPerform')->value($retries)->type(''), SOAP::Data->name('CSID')->value($csid)->type(''), SOAP::Data->name('PageHeader')->value($pageHeader)->type(''), SOAP::Data->name('JobID')->value('')->type(''), SOAP::Data->name('Subject')->value($subject)->type(''), SOAP::Data->name('ReplyAddress')->value($replyEmail)->type(''), SOAP::Data->name('PageSize')->value($pageSize)->type(''), SOAP::Data->name('PageOrientation')->value($pageOrientation)->type(''), SOAP::Data->name('IsHighResolution')->value($highResolution)->type(''), SOAP::Data->name('IsFineRendering')->value($fineRendering)->type('') ); if ( $result->fault ) { print $result->faultstring . "\n"; } else { if( $result->valueof('//SendfaxEx_2Result') > 0 ) { print "Success. TransactionID=" . $result->valueof('//SendfaxEx_2Result') . "\n"; } else { print "Error, return code=" . $result->valueof('//SendfaxEx_2Result') . "\n"; } }