use IPC::Open3;
use POSIX qw(:sys_wait_h strftime);
-use Time::HiRes qw(usleep);
+use Time::HiRes qw(usleep gettimeofday);
use Mail::Address ();
use Debbugs::MIME qw(encode_rfc1522);
use Debbugs::Config qw(:config);
use Params::Validate qw(:types validate_with);
+use Encode qw(encode is_utf8);
+
+use Debbugs::Packages;
BEGIN{
($VERSION) = q$Revision: 1.1 $ =~ /^Revision:\s+([^\s+])/;
# calculate our headers
my $bug_num = exists $param{data} ? $param{data}{bug_num} : 'x';
- my $nn = $param{queue_file};
+ my $nn = exists $param{queue_file} ? $param{queue_file} : join('',gettimeofday());
# handle the user giving the actual queue filename instead of nn
$nn =~ s/^[a-zA-Z]([a-zA-Z])/$1/;
$nn = lc($nn);
$default_header{"X-$config{project}-PR-Source"} = $1;
}
else {
- my $pkg_src = getpkgsrc();
+ my $pkg_src = Debbugs::Packages::getpkgsrc();
$default_header{"X-$config{project}-PR-Source"} = $pkg_src->{$param{data}{package}};
}
}
($header,$default_header{$header});
}
else {
- push @other_headers,($header,$header_order{lc($header)});
+ push @other_headers,($header,$default_header{$header});
}
}
my @headers;
sub send_mail_message{
my %param = validate_with(params => \@_,
spec => {sendmail_arguments => {type => ARRAYREF,
- default => [qw(-odq -oem -oi)],
+ default => $config{sendmail_arguments},
},
parse_for_recipients => {type => BOOLEAN,
default => 0,
},
},
);
- my @sendmail_arguments = qw(-odq -oem -oi);
+ my @sendmail_arguments = @{$param{sendmail_arguments}};
push @sendmail_arguments, '-f', $param{envelope_from} if exists $param{envelope_from};
my @recipients;
if ($param{encode_headers}) {
$param{message} = encode_headers($param{message});
}
+ eval {
+ if (is_utf8($param{message})) {
+ $param{message} = encode('utf8',$param{message});
+ }
+ };
# First, try to send the message as is.
eval {