Suppress images for short emails

This commit is contained in:
Arpit Jalan
2014-09-13 10:56:31 +05:30
parent 42104685f7
commit 0a64657fab
4 changed files with 24 additions and 1 deletions

View File

@@ -94,6 +94,12 @@ module Email
@message.header['X-Discourse-Post-Id'] = nil
@message.header['X-Discourse-Reply-Key'] = nil
# Suppress images from short emails
if SiteSetting.strip_images_from_short_emails && @message.html_part.body.to_s.bytesize <= SiteSetting.short_email_length && @message.html_part.body =~ /<img[^>]+>/
style = Email::Styles.new(@message.html_part.body.to_s)
@message.html_part.body = style.strip_avatars_and_emojis
end
begin
@message.deliver
rescue *SMTP_CLIENT_ERRORS => e