From b62e2bedbfa49aacfc4847049aa589f045af15ce Mon Sep 17 00:00:00 2001 From: Ruben Davila Date: Mon, 28 Nov 2016 17:00:03 -0500 Subject: Add new configuration setting to enable/disable HTML 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. --- lib/email_template_interceptor.rb | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 lib/email_template_interceptor.rb (limited to 'lib/email_template_interceptor.rb') 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 -- cgit v1.2.3