diff options
author | Sean McGivern <sean@mcgivern.me.uk> | 2017-02-16 09:33:32 +0000 |
---|---|---|
committer | Sean McGivern <sean@mcgivern.me.uk> | 2017-02-16 09:33:32 +0000 |
commit | 93ae3063ad0455a0bd6b9994f718d20357a31e28 (patch) | |
tree | 75321fd1299c68dc1499f6a881b36071d204ff67 | |
parent | 8b955e4eb6eb92138cbc6849dfc5dc8bece5c2ae (diff) | |
parent | a89e9736266cbf9ccde3a49eccd8ab04f72bf38f (diff) | |
download | gitlab-ce-93ae3063ad0455a0bd6b9994f718d20357a31e28.tar.gz |
Merge branch 'add-auto-submited-header' into 'master'
Set `Auto-Submitted: auto-generated` header to emails
Closes #20305
See merge request !9163
4 files changed, 25 insertions, 0 deletions
diff --git a/changelogs/unreleased/add-auto-submited-header.yml b/changelogs/unreleased/add-auto-submited-header.yml new file mode 100644 index 00000000000..93481613b39 --- /dev/null +++ b/changelogs/unreleased/add-auto-submited-header.yml @@ -0,0 +1,4 @@ +--- +title: Set Auto-Submitted header to mails +merge_request: +author: Semyon Pupkov diff --git a/config/initializers/additional_headers_interceptor.rb b/config/initializers/additional_headers_interceptor.rb new file mode 100644 index 00000000000..b9159e7c06c --- /dev/null +++ b/config/initializers/additional_headers_interceptor.rb @@ -0,0 +1 @@ +ActionMailer::Base.register_interceptor(AdditionalEmailHeadersInterceptor) diff --git a/lib/additional_email_headers_interceptor.rb b/lib/additional_email_headers_interceptor.rb new file mode 100644 index 00000000000..2358fa6bbfd --- /dev/null +++ b/lib/additional_email_headers_interceptor.rb @@ -0,0 +1,8 @@ +class AdditionalEmailHeadersInterceptor + def self.delivering_email(message) + message.headers( + 'Auto-Submitted' => 'auto-generated', + 'X-Auto-Response-Suppress' => 'All' + ) + end +end diff --git a/spec/lib/additional_email_headers_interceptor_spec.rb b/spec/lib/additional_email_headers_interceptor_spec.rb new file mode 100644 index 00000000000..580450eef1e --- /dev/null +++ b/spec/lib/additional_email_headers_interceptor_spec.rb @@ -0,0 +1,12 @@ +require 'spec_helper' + +describe AdditionalEmailHeadersInterceptor do + it 'adds Auto-Submitted header' do + mail = ActionMailer::Base.mail(to: 'test@mail.com', from: 'info@mail.com', body: 'hello').deliver + + expect(mail.header['To'].value).to eq('test@mail.com') + expect(mail.header['From'].value).to eq('info@mail.com') + expect(mail.header['Auto-Submitted'].value).to eq('auto-generated') + expect(mail.header['X-Auto-Response-Suppress'].value).to eq('All') + end +end |