send-t-shirts: Improve email line processing.
This commit is contained in:
parent
1508660842
commit
07593c7b15
1 changed files with 22 additions and 5 deletions
|
@ -75,11 +75,28 @@ foreach my $id (sort keys %idsSent) {
|
||||||
next;
|
next;
|
||||||
}
|
}
|
||||||
next unless $sp->emailOk($id);
|
next unless $sp->emailOk($id);
|
||||||
my $emailTo = $sp->getPreferredEmailAddress($id);
|
my @emails;
|
||||||
if (not defined $emailTo) {
|
my $preferredEmail = $sp->getPreferredEmailAddress($id);
|
||||||
my(@addr) = $sp->getEmailAddresses($id);
|
if (defined $preferredEmail) {
|
||||||
$emailTo = $addr[0];
|
push(@emails, $preferredEmail);
|
||||||
|
} else {
|
||||||
|
my(%emailData) = $sp->getEmailAddresses($id);
|
||||||
|
(@emails) = keys %emailData;
|
||||||
}
|
}
|
||||||
|
my $fullEmailLine = "";
|
||||||
|
my $emailTo = join(' ', @emails);
|
||||||
|
my $displayName = $sp->getDisplayName($id);
|
||||||
|
print "Email to:$emailTo, displayName $displayName\n";
|
||||||
|
foreach my $email (@emails) {
|
||||||
|
$fullEmailLine .= ", " if ($fullEmailLine ne "");
|
||||||
|
my $line = "";
|
||||||
|
if (defined $displayName) {
|
||||||
|
$line .= "\"$displayName\" ";
|
||||||
|
}
|
||||||
|
$line .= "<$email>";
|
||||||
|
$fullEmailLine .= Encode::encode("MIME-Header", $line);
|
||||||
|
}
|
||||||
|
|
||||||
my $fromAddress = 'info@sfconservancy.org';
|
my $fromAddress = 'info@sfconservancy.org';
|
||||||
my $pingNoGet = "";
|
my $pingNoGet = "";
|
||||||
$pingNoGet = "\nPlease ping us if you do not receive your t-shirt within two weeks in the\nUSA, or three weeks outside of the USA.\n\n"
|
$pingNoGet = "\nPlease ping us if you do not receive your t-shirt within two weeks in the\nUSA, or three weeks outside of the USA.\n\n"
|
||||||
|
@ -88,7 +105,7 @@ foreach my $id (sort keys %idsSent) {
|
||||||
open(SENDMAIL, "|/usr/lib/sendmail -f \"$fromAddress\" -oi -oem -- $emailTo $fromAddress") or
|
open(SENDMAIL, "|/usr/lib/sendmail -f \"$fromAddress\" -oi -oem -- $emailTo $fromAddress") or
|
||||||
die "unable to run sendmail: $!";
|
die "unable to run sendmail: $!";
|
||||||
print SENDMAIL <<DATA;
|
print SENDMAIL <<DATA;
|
||||||
To: $emailTo
|
To: $fullEmailLine
|
||||||
From: "Software Freedom Conservancy" <$fromAddress>
|
From: "Software Freedom Conservancy" <$fromAddress>
|
||||||
Subject: $sizesSent Conservancy T-Shirt was $HOW
|
Subject: $sizesSent Conservancy T-Shirt was $HOW
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue