Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDouwe Maan <douwe@gitlab.com>2015-08-19 21:10:21 +0300
committerDouwe Maan <douwe@gitlab.com>2015-08-19 21:10:21 +0300
commit76dbafba86dda96b7ba2f93fc7e07eea3ca48302 (patch)
treea656779e1819fa65db805b6be09c9e009f2f92ea /app/mailers/email_rejection_mailer.rb
parent170aa3b43b5186f73b149eae6b80b96a9b1171b2 (diff)
Send a rejection email when the incoming email couldn't be processed.
Diffstat (limited to 'app/mailers/email_rejection_mailer.rb')
-rw-r--r--app/mailers/email_rejection_mailer.rb35
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