Read about our upcoming Code of Conduct on this issue

email_rejection_mailer.rb 709 Bytes
Newer Older
gfyoung's avatar
gfyoung committed
1
2
# frozen_string_literal: true

3
class EmailRejectionMailer < ApplicationMailer
4
5
6
7
  layout 'empty_mailer'

  helper EmailsHelper

8
9
10
11
  def rejection(reason, original_raw, can_retry = false)
    @reason = reason
    @original_message = Mail::Message.new(original_raw)

Douwe Maan's avatar
Douwe Maan committed
12
13
    return unless @original_message.from

14
15
16
17
18
    headers = {
      to: @original_message.from,
      subject: "[Rejected] #{@original_message.subject}"
    }

19
    headers['Message-ID'] = "<#{SecureRandom.hex}@#{Gitlab.config.gitlab.host}>"
20
21
22
23
24
25
26
27
    headers['In-Reply-To'] = @original_message.message_id
    headers['References'] = @original_message.message_id

    headers['Reply-To'] = @original_message.to.first if can_retry

    mail(headers)
  end
end