-push @ssh_arguments, q(cat - | /usr/lib/sendmail ).$options{'sendmail-options'}.' '.join(' ',@recipients);
-qx(ping -q -c 3 $hostname 2>/dev/null);
+my @sendmail_options;
+push @sendmail_options,
+ ref($options{sendmail_options})?@{$options{sendmail_options}}:$options{sendmail_options};
+push @sendmail_options,@recipients;
+$Data::Dumper::Useqq=1;
+my $sendmail_options = Data::Dumper->Dump([\@sendmail_options],[qw(*sendmail_options)]);
+print STDERR $sendmail_options if $DEBUG;
+push @ssh_arguments, q(perl -e ').<<EOF .q(');
+use Digest::MD5 qw(md5_hex);
+use IO::Handle;
+my \@message = <>;
+my $sendmail_options
+my \$digest = pop \@message;
+\$digest =~ /(.*)([0-9a-fA-F]{32})\n/;
+\$digest = \$2;
+if (length \$1) {
+ push \@message,\$1;
+}
+my \$message = join(q(),\@message);
+if (\$digest eq md5_hex(\$message)) {
+ my \$sendmail = IO::Handle->new();
+ open (\$sendmail,q(|-),q(/usr/lib/sendmail), \@sendmail_options) or
+ die "Unable to open sendmail: \$!";
+ print {\$sendmail} \$message or
+ die "Unable to write to sendmail: \$!";
+ close (\$sendmail) or
+ die "Unable to close sendmail: \$!";
+} else {
+ die "Digest failure! \$digest vs ".md5_hex(\$message);
+}
+EOF
+
+$Data::Dumper::Useqq=0;
+print STDERR Dumper(\@ssh_arguments) if $DEBUG;
+
+qx(ping -q -w 3 -c 1 $options{host} 2>/dev/null);