Skip to content

Commit 6fb897a

Browse files
committed
paused: use email header objects for email headers
1 parent fb72ca9 commit 6fb897a

File tree

1 file changed

+51
-47
lines changed

1 file changed

+51
-47
lines changed

bin/paused

Lines changed: 51 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ package mypause_send_mail;
133133
use PAUSE::Logger '$Logger';
134134

135135
sub send {
136-
my($self,$header,$blurb) = @_;
136+
my ($self,$header,$blurb) = @_;
137137

138138
my %from = exists $header->{From}
139139
? ()
@@ -308,7 +308,7 @@ skip =not yet verified
308308

309309

310310
mypause_send_mail->send({
311-
To => $PAUSE::Config->{INTERNAL_REPORT_ADDRESS},
311+
To => PAUSE::Email->admin_email_header_object,
312312
Subject => "Mirror request from $package"
313313
},
314314
$blurb
@@ -397,10 +397,8 @@ sub woe {
397397
# fullname just to reuse sth2
398398
$asciiname ||= $fullname;
399399
$asciiname =~ s/[^\0-\177]/?/g;
400-
my @To;
400+
401401
my $pma = PAUSE::MailAddress->new_from_userid($userid);
402-
my $to = $pma->address;
403-
push @To, $PAUSE::Config->{INTERNAL_REPORT_ADDRESS}, qq{"$asciiname" <$to>};
404402

405403
my $blurb = "The URL $hash->{uri},
406404
requested for upload as $hash->{uriid} has problems
@@ -412,13 +410,17 @@ new trial.
412410
Virtually Yours,
413411
$Id\n";
414412

415-
for my $to (@To) {
416-
mypause_send_mail->send({
417-
To => join(",",$to),
418-
Subject => "Upload problem $hash->{uriid}"
419-
},
420-
$blurb
421-
);
413+
for my $to (
414+
$pma->email_header_object,
415+
PAUSE::Email->admin_email_header_object,
416+
) {
417+
mypause_send_mail->send(
418+
{
419+
To => $to,
420+
Subject => "Upload problem $hash->{uriid}"
421+
},
422+
$blurb
423+
);
422424
}
423425

424426
} elsif ($hash->{nosuccesscount} == $PAUSE::Config->{MAXRETRIES}) {
@@ -468,10 +470,8 @@ but I couldn't ($!). Seems as if the admin has to do something\n\n";
468470
my($fullname, $asciiname) = $sth2->fetchrow_array;
469471
$asciiname ||= $fullname;
470472
$asciiname =~ s/[^\0-\177]/?/g;
471-
my @To;
473+
472474
my $pma = PAUSE::MailAddress->new_from_userid($userid);
473-
my $address = $pma->address;
474-
push @To, $PAUSE::Config->{INTERNAL_REPORT_ADDRESS}, qq{"$asciiname" <$address>};
475475

476476
my $blurb;
477477
if ($self->{ErrNotGzip}) {
@@ -495,13 +495,17 @@ Virtually Yours,
495495
$Id\n";
496496
}
497497

498-
for my $to (@To) {
499-
mypause_send_mail->send({
500-
To => join(",",$to),
501-
Subject => "Upload problem $hash->{uriid}"
502-
},
503-
$blurb
504-
);
498+
for my $to (
499+
$pma->email_header_object,
500+
PAUSE::Email->admin_email_header_object,
501+
) {
502+
mypause_send_mail->send(
503+
{
504+
To => $to,
505+
Subject => "Upload problem $hash->{uriid}"
506+
},
507+
$blurb
508+
);
505509
}
506510

507511
# don't writeback, it would defeat removing it.
@@ -532,14 +536,6 @@ sub welcome_file {
532536
$asciiname ||= $fullname;
533537
$asciiname =~ s/[^\0-\177]/?/g;
534538
my $dbh = $self->{DBH};
535-
my $pma = PAUSE::MailAddress->new_from_userid($userid);
536-
my $address = $pma->address;
537-
my @To = qq{"$asciiname" <$address>};
538-
unless ($PAUSE::Config->{TESTHOST}) {
539-
push @To, $PAUSE::Config->{TO_CPAN_TESTERS};
540-
push @To, $PAUSE::Config->{'P5P'} if
541-
$hash->{'mailto_p5p'}==1;
542-
}
543539

544540
my $blurb = "The URL";
545541
$blurb = "The uploaded file" if $hash->{uri} !~ m,/,;
@@ -585,14 +581,24 @@ CPAN Testers will start reporting results in an hour or so:
585581
"Thanks,\n-- \n$Id"
586582
);
587583

584+
my $pma = PAUSE::MailAddress->new_from_userid($userid);
585+
my @To = $pma->email_header_object;
586+
587+
unless ($PAUSE::Config->{TESTHOST}) {
588+
push @To, PAUSE::Email->email_header_object_for_addresses(
589+
Email::Address::XS->new('CPAN Testers', $PAUSE::Config->{TO_CPAN_TESTERS}),
590+
);
591+
}
592+
588593
for my $to (@To) {
589-
mypause_send_mail->send({
590-
To => join(",",$to),
591-
Subject => "CPAN Upload: $hash->{uriid}",
592-
"Reply-To" => $PAUSE::Config->{REPLY_TO_CPAN_TESTERS},
593-
},
594-
$blurb
595-
);
594+
mypause_send_mail->send(
595+
{
596+
To => $to,
597+
Subject => "CPAN Upload: $hash->{uriid}",
598+
"Reply-To" => $PAUSE::Config->{REPLY_TO_CPAN_TESTERS},
599+
},
600+
$blurb
601+
);
596602
}
597603
$self->logge("Info: Sent 'has entered' email about uriid[$hash->{uriid}]");
598604
sleep 10;
@@ -775,7 +781,6 @@ sub verify_gzip_tar {
775781
if ($child_stat != 0) {
776782
$err =~ s/\n/ /g;
777783
$self->logge("Debug: child_stat[$child_stat]err[$err]");
778-
my @To = $PAUSE::Config->{INTERNAL_REPORT_ADDRESS};
779784

780785
my $blurb = "For the resource [$uri]
781786
the command [$testinggzip -t $tpath]
@@ -785,15 +790,14 @@ sub verify_gzip_tar {
785790
The command [ls -l $tpath]
786791
gives [$ls]\n\n";
787792

788-
for my $to (@To) {
789-
mypause_send_mail->send
790-
({
791-
To => $to,
792-
Subject => "Upload problem $uri"
793-
},
794-
$blurb
795-
);
796-
}
793+
mypause_send_mail->send(
794+
{
795+
To => PAUSE::Email->admin_email_header_object,
796+
Subject => "Upload problem $uri"
797+
},
798+
$blurb
799+
);
800+
797801
if ($err =~ /not in gzip format/) {
798802
$self->{URIRECORD}{nosuccesscount} = $PAUSE::Config->{MAXRETRIES} - 1;
799803
$self->{ErrNotGzip}++;

0 commit comments

Comments
 (0)