From 522df6bbfa3a5394072dd4a4c02a3037cdf62f25 Mon Sep 17 00:00:00 2001 From: "Bradley M. Kuhn" Date: Fri, 2 Dec 2016 12:56:53 -0800 Subject: [PATCH] add display_name to outgoing email. In an effort to improve the formatting on outgoing emails from the renewal script, add the display_name to the To: field. I'm not completely happy with what the MIME encoding is doing here. Specifically, it chops the line on the < of so you get this: "A very long name that leads to wrapping of the MIME encoded line" < email@example.org> As I read https://www.ietf.org/rfc/rfc2822.txt, it violates this SHOULD: Note: Though structured field bodies are defined in such a way that folding can take place between many of the lexical tokens (and even within some of the lexical tokens), folding SHOULD be limited to placing the CRLF at higher-level syntactic breaks. For instance, if a field body is defined as comma-separated values, it is recommended that folding occur after the comma separating the structured items in preference to other places where the field could be folded, even if it is allowed elsewhere. Brett and I decided to leave it for now and go with it. --- scripts/send-renewal-notices.plx | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/scripts/send-renewal-notices.plx b/scripts/send-renewal-notices.plx index 1c6166f..84fec50 100644 --- a/scripts/send-renewal-notices.plx +++ b/scripts/send-renewal-notices.plx @@ -2,6 +2,8 @@ use strict; use warnings; +use Encode; +use utf8; use autodie qw(open close); @@ -116,11 +118,22 @@ foreach my $supporterId (@supporterIds) { } close MESSAGE; my $emailTo = join(' ', @emails); + my $displayName = $sp->getDisplayName($supporterId); + my $fullEmailLine = ""; + foreach my $email (@emails) { + $fullEmailLine .= ", " if ($fullEmailLine ne ""); + my $line = ""; + if (defined $displayName) { + $line .= "\"$displayName\" "; + } + $line .= "<$email>"; + $fullEmailLine .= Encode::encode("MIME-Header", $line); + } open(SENDMAIL, "|/usr/lib/sendmail -f \"$FROM_ADDRESS\" -oi -oem -- $emailTo $FROM_ADDRESS") or die "unable to run sendmail: $!"; print STDERR "Sending to $supporterId at $emailTo who expires on $expiresOn\n"; - print SENDMAIL "To: ", join(', ', @emails), "\n"; + print SENDMAIL "To: $fullEmailLine\n"; print SENDMAIL @message; close SENDMAIL;