MT#14923 sendfax allow trying multiple ips

Change-Id: Ib3764d4ef32b7c76e9848264fda429d5c8bee361
changes/48/2548/5
Gerhard Jungwirth 10 years ago
parent d7a84f89bc
commit 753adadf6b

@ -35,8 +35,15 @@ sub send_fax {
} else {
push @sendfax_args, '-o '.$number;
}
push @sendfax_args, '-h '.($c->config->{faxserver}->{ip} // '127.0.0.1');
my $hosts_config = $c->config->{faxserver}->{ip};
my @hosts;
if(ref($hosts_config) eq "ARRAY") {
@hosts = @{$hosts_config};
} else {
@hosts = ($hosts_config // '127.0.0.1',);
}
if($args{notify}) {
push @sendfax_args, '-D';
push @sendfax_args, "-f '$sender <$args{notify}>'";
@ -71,13 +78,16 @@ sub send_fax {
} else {
$filename = eval { $args{upload}->tempname };
}
push @sendfax_args, $filename;
my $sa = join(' ', @sendfax_args);
my $output = `$sendfax $sa 2>&1`;
my $exit = $?;
unlink $filename;
my ($exit,$output);
for my $host (@hosts) {
$output = `$sendfax $sa -h $host $filename 2>&1`;
$exit = $?;
last if $exit eq '0';
}
unlink $filename;
if($exit ne '0') {
chomp $output;
die $output."\n";

Loading…
Cancel
Save