diff options
author | Douwe Maan <douwe@gitlab.com> | 2015-08-19 11:10:21 -0700 |
---|---|---|
committer | Douwe Maan <douwe@gitlab.com> | 2015-08-19 11:10:21 -0700 |
commit | 76dbafba86dda96b7ba2f93fc7e07eea3ca48302 (patch) | |
tree | a656779e1819fa65db805b6be09c9e009f2f92ea /app/mailers | |
parent | 170aa3b43b5186f73b149eae6b80b96a9b1171b2 (diff) | |
download | gitlab-ce-76dbafba86dda96b7ba2f93fc7e07eea3ca48302.tar.gz |
Send a rejection email when the incoming email couldn't be processed.
Diffstat (limited to 'app/mailers')
-rw-r--r-- | app/mailers/email_rejection_mailer.rb | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/app/mailers/email_rejection_mailer.rb b/app/mailers/email_rejection_mailer.rb new file mode 100644 index 00000000000..f29c4e052fc --- /dev/null +++ b/app/mailers/email_rejection_mailer.rb @@ -0,0 +1,35 @@ +class EmailRejectionMailer < ActionMailer::Base + add_template_helper ApplicationHelper + add_template_helper GitlabMarkdownHelper + + helper_method :current_user, :can? + + default from: "#{Gitlab.config.gitlab.email_display_name} <#{Gitlab.config.gitlab.email_from}>" + default reply_to: "#{Gitlab.config.gitlab.email_display_name} <#{Gitlab.config.gitlab.email_reply_to}>" + + def rejection(reason, original_raw, can_retry = false) + @reason = reason + @original_message = Mail::Message.new(original_raw) + + headers = { + to: @original_message.from, + subject: "[Rejected] #{@original_message.subject}" + } + + headers['Message-ID'] = SecureRandom.hex + 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 + + def current_user + nil + end + + def can? + false + end +end |