Set Auto-Submitted: auto-generated
header to emails
Closes https://gitlab.com/gitlab-org/gitlab-ce/issues/20305
This commit is contained in:
parent
5e95296278
commit
a89e973626
4 changed files with 25 additions and 0 deletions
4
changelogs/unreleased/add-auto-submited-header.yml
Normal file
4
changelogs/unreleased/add-auto-submited-header.yml
Normal file
|
@ -0,0 +1,4 @@
|
|||
---
|
||||
title: Set Auto-Submitted header to mails
|
||||
merge_request:
|
||||
author: Semyon Pupkov
|
1
config/initializers/additional_headers_interceptor.rb
Normal file
1
config/initializers/additional_headers_interceptor.rb
Normal file
|
@ -0,0 +1 @@
|
|||
ActionMailer::Base.register_interceptor(AdditionalEmailHeadersInterceptor)
|
8
lib/additional_email_headers_interceptor.rb
Normal file
8
lib/additional_email_headers_interceptor.rb
Normal file
|
@ -0,0 +1,8 @@
|
|||
class AdditionalEmailHeadersInterceptor
|
||||
def self.delivering_email(message)
|
||||
message.headers(
|
||||
'Auto-Submitted' => 'auto-generated',
|
||||
'X-Auto-Response-Suppress' => 'All'
|
||||
)
|
||||
end
|
||||
end
|
12
spec/lib/additional_email_headers_interceptor_spec.rb
Normal file
12
spec/lib/additional_email_headers_interceptor_spec.rb
Normal file
|
@ -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
|
Loading…
Reference in a new issue