From 32427b2032b12a7195249a2041e7aaa420b06e6a Mon Sep 17 00:00:00 2001 From: Matthew Somerville Date: Fri, 25 Mar 2016 21:30:44 +0000 Subject: Refactor email handling to use Email::MIME alone. --- t/app/helpers/send_email.t | 3 +- t/app/helpers/send_email_sample.txt | 4 +- t/app/helpers/send_email_sample_mime.txt | 106 ++++++++++++++----------------- 3 files changed, 51 insertions(+), 62 deletions(-) (limited to 't/app/helpers') diff --git a/t/app/helpers/send_email.t b/t/app/helpers/send_email.t index f60f7fa5a..e2c8688a8 100644 --- a/t/app/helpers/send_email.t +++ b/t/app/helpers/send_email.t @@ -41,8 +41,7 @@ my $email = Email::MIME->new($email_as_string); my $expected_email_content = path(__FILE__)->parent->child('send_email_sample.txt')->slurp; my $name = FixMyStreet->config('CONTACT_NAME'); -$name = "\"$name\"" if $name =~ / /; -my $sender = $name . ' <' . FixMyStreet->config('DO_NOT_REPLY_EMAIL') . '>'; +my $sender = '"' . $name . '" <' . FixMyStreet->config('DO_NOT_REPLY_EMAIL') . '>'; $expected_email_content =~ s{CONTACT_EMAIL}{$sender}; my $expected_email = Email::MIME->new($expected_email_content); diff --git a/t/app/helpers/send_email_sample.txt b/t/app/helpers/send_email_sample.txt index 1ccce6a23..0f7406172 100644 --- a/t/app/helpers/send_email_sample.txt +++ b/t/app/helpers/send_email_sample.txt @@ -1,5 +1,5 @@ MIME-Version: 1.0 -Subject: test email =?utf-8?Q?=E2=98=BA?= +Subject: =?UTF-8?B?dGVzdCBlbWFpbCDimLo=?= Content-Type: text/plain; charset="utf-8" To: test@recipient.com Content-Transfer-Encoding: quoted-printable @@ -24,5 +24,3 @@ culpa qui officia deserunt mollit anim id est laborum. Yours,=20=20 FixMyStreet.=20= - - diff --git a/t/app/helpers/send_email_sample_mime.txt b/t/app/helpers/send_email_sample_mime.txt index c4ca97bcc..0649d1ceb 100644 --- a/t/app/helpers/send_email_sample_mime.txt +++ b/t/app/helpers/send_email_sample_mime.txt @@ -1,57 +1,49 @@ -MIME-Version: 1.0 -Subject: test email =?utf-8?Q?=E2=98=BA?= -Content-Type: multipart/mixed; boundary="BOUNDARY" -To: test@recipient.com -Content-Transfer-Encoding: 7bit -From: CONTACT_EMAIL - - ---BOUNDARY -MIME-Version: 1.0 -Subject: test email =?utf-8?Q?=E2=98=BA?= -Content-Type: text/plain; charset="utf-8" -To: test@recipient.com -Content-Transfer-Encoding: quoted-printable -From: CONTACT_EMAIL - -Hello, - -This is a test email where foo: bar. - -utf8: =E6=88=91=E4=BB=AC=E5=BA=94=E8=AF=A5=E8=83=BD=E5=A4=9F=E6=97=A0=E7=BC= -=9D=E5=A4=84=E7=90=86UTF8=E7=BC=96=E7=A0=81 - - indented_text - -long line: Lorem ipsum dolor sit amet, consectetur adipisicing elit, -sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. -Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris -nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in -reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla -pariatur. Excepteur sint occaecat cupidatat non proident, sunt in -culpa qui officia deserunt mollit anim id est laborum. - -Yours,=20=20 -FixMyStreet.=20= - - - ---BOUNDARY -MIME-Version: 1.0 -Content-Type: image/gif; name="foo.gif" -Content-Disposition: inline; filename="foo.gif" -Content-Transfer-Encoding: quoted-printable - -GIF89a=01=00=01=00=80=00=00=00=00=00=CC=CC=CC,=00=00=00=00=01=00=01=00=00= -=02=01L=00;= - ---BOUNDARY -MIME-Version: 1.0 -Content-Type: image/gif; name="bar.gif" -Content-Disposition: inline; filename="bar.gif" -Content-Transfer-Encoding: quoted-printable - -GIF89a=01=00=01=00=80=00=00=00=00=00=CC=CC=CC,=00=00=00=00=01=00=01=00=00= -=02=01L=00;= - ---BOUNDARY-- +MIME-Version: 1.0 +Subject: =?UTF-8?B?dGVzdCBlbWFpbCDimLo=?= +Content-Type: multipart/mixed; boundary="BOUNDARY" +To: test@recipient.com +Content-Transfer-Encoding: 7bit +From: CONTACT_EMAIL + + +--BOUNDARY +Content-Type: text/plain; charset="utf-8" +Content-Transfer-Encoding: quoted-printable + +Hello, + +This is a test email where foo: bar. + +utf8: =E6=88=91=E4=BB=AC=E5=BA=94=E8=AF=A5=E8=83=BD=E5=A4=9F=E6=97=A0=E7=BC= +=9D=E5=A4=84=E7=90=86UTF8=E7=BC=96=E7=A0=81 + + indented_text + +long line: Lorem ipsum dolor sit amet, consectetur adipisicing elit, +sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. +Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris +nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in +reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla +pariatur. Excepteur sint occaecat cupidatat non proident, sunt in +culpa qui officia deserunt mollit anim id est laborum. + +Yours,=20=20 +FixMyStreet.=20= + +--BOUNDARY +Content-Type: image/gif; name="foo.gif" +Content-Disposition: inline; filename="foo.gif" +Content-Transfer-Encoding: quoted-printable + +GIF89a=01=00=01=00=80=00=00=00=00=00=CC=CC=CC,=00=00=00=00=01=00=01=00=00= +=02=01L=00;= + +--BOUNDARY +Content-Type: image/gif; name="bar.gif" +Content-Disposition: inline; filename="bar.gif" +Content-Transfer-Encoding: quoted-printable + +GIF89a=01=00=01=00=80=00=00=00=00=00=CC=CC=CC,=00=00=00=00=01=00=01=00=00= +=02=01L=00;= + +--BOUNDARY-- -- cgit v1.2.3