diff options
-rw-r--r-- | perllib/FixMyStreet/App.pm | 4 | ||||
-rw-r--r-- | t/app/helpers/send_email.t | 3 |
2 files changed, 6 insertions, 1 deletions
diff --git a/perllib/FixMyStreet/App.pm b/perllib/FixMyStreet/App.pm index 68bfc728b..beea8bb11 100644 --- a/perllib/FixMyStreet/App.pm +++ b/perllib/FixMyStreet/App.pm @@ -296,6 +296,10 @@ sub send_email { $email->header_set( ucfirst($_), $vars->{$_} ) for grep { $vars->{$_} } qw( to from subject); + $email->header_set( 'Message-ID', sprintf('<fms-%s-%s@%s>', + time(), unpack('h*', random_bytes(5, 1)), $c->config->{EMAIL_DOMAIN} + ) ); + # pass the email into mySociety::Email to construct the on the wire 7bit # format - this should probably happen in the transport instead but hohum. my $email_text = mySociety::Locale::in_gb_locale { mySociety::Email::construct_email( diff --git a/t/app/helpers/send_email.t b/t/app/helpers/send_email.t index ac7e5b5c2..8c043f701 100644 --- a/t/app/helpers/send_email.t +++ b/t/app/helpers/send_email.t @@ -9,7 +9,7 @@ BEGIN { FixMyStreet->test_mode(1); } -use Test::More tests => 5; +use Test::More tests => 6; use Email::Send::Test; use Path::Class; @@ -44,6 +44,7 @@ is scalar(@emails), 1, "caught one email"; # Get the email, check it has a date and then strip it out my $email_as_string = $emails[0]->as_string; ok $email_as_string =~ s{\s+Date:\s+\S.*?$}{}xms, "Found and stripped out date"; +ok $email_as_string =~ s{\s+Message-ID:\s+\S.*?$}{}xms, "Found and stripped out message ID (contains epoch)"; my $expected_email_content = file(__FILE__)->dir->file('send_email_sample.txt')->slurp; my $name = FixMyStreet->config('CONTACT_NAME'); |