summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorRuben Davila <rdavila84@gmail.com>2016-11-28 17:00:03 -0500
committerRuben Davila <rdavila84@gmail.com>2016-11-28 17:00:03 -0500
commitb62e2bedbfa49aacfc4847049aa589f045af15ce (patch)
tree6bf1896177f66219f019beda752261fa7b99cea1 /lib
parent5c6d3a99efa1d29291f0b58655d9fc7febb970f8 (diff)
downloadgitlab-ce-b62e2bedbfa49aacfc4847049aa589f045af15ce.tar.gz
Add new configuration setting to enable/disable HTML emails.24880-configurable-plaintext-emails
This new global setting will allow admins to specify if HTML emails should be sent or not, this is basically useful when system administrators want to save some disk space by avoiding emails in HTML format and using only the Plain Text version.
Diffstat (limited to 'lib')
-rw-r--r--lib/email_template_interceptor.rb13
1 files changed, 13 insertions, 0 deletions
diff --git a/lib/email_template_interceptor.rb b/lib/email_template_interceptor.rb
new file mode 100644
index 00000000000..fb04a7824b8
--- /dev/null
+++ b/lib/email_template_interceptor.rb
@@ -0,0 +1,13 @@
+# Read about interceptors in http://guides.rubyonrails.org/action_mailer_basics.html#intercepting-emails
+class EmailTemplateInterceptor
+ include Gitlab::CurrentSettings
+
+ def self.delivering_email(message)
+ # Remove HTML part if HTML emails are disabled.
+ unless current_application_settings.html_emails_enabled
+ message.part.delete_if do |part|
+ part.content_type.try(:start_with?, 'text/html')
+ end
+ end
+ end
+end