diff --git a/app/lib/server/startup/email.js b/app/lib/server/startup/email.js index d31d4de65a59a..852618fd1a1cb 100644 --- a/app/lib/server/startup/email.js +++ b/app/lib/server/startup/email.js @@ -2,6 +2,10 @@ import { settings } from '../../../settings'; settings.addGroup('Email', function() { this.section('Style', function() { + this.add('email_plain_text_only', false, { + type: 'boolean', + }); + this.add('email_style', `html, body, .body { font-family: -apple-system,BlinkMacSystemFont,'Segoe UI',Roboto,Oxygen,Ubuntu,Cantarell,'Helvetica Neue','Apple Color Emoji','Segoe UI Emoji','Segoe UI Symbol','Meiryo UI',Arial,sans-serif; } body, .body { @@ -103,6 +107,10 @@ settings.addGroup('Email', function() { multiline: true, i18nLabel: 'email_style_label', i18nDescription: 'email_style_description', + enableQuery: { + _id: 'email_plain_text_only', + value: false, + }, }); }); diff --git a/app/mailer/server/api.js b/app/mailer/server/api.js index bcfdec4ffe203..45c7f10030f31 100644 --- a/app/mailer/server/api.js +++ b/app/mailer/server/api.js @@ -50,7 +50,13 @@ export const replaceEscaped = (str, data = {}) => replace(str, { return ret; }, {}), }); -export const wrap = (html, data = {}) => replaceEscaped(body.replace('{{body}}', html), data); +export const wrap = (html, data = {}) => { + if (settings.get('email_plain_text_only')) { + return replace(html, data); + } + + return replaceEscaped(body.replace('{{body}}', html), data); +}; export const inlinecss = (html) => juice.inlineContent(html, Settings.get('email_style')); export const getTemplate = (template, fn, escape = true) => { let html = ''; @@ -103,6 +109,10 @@ export const sendNoWrap = ({ to, from, replyTo, subject, html, text, headers }) text = stripHtml(html); } + if (settings.get('email_plain_text_only')) { + html = undefined; + } + Meteor.defer(() => Email.send({ to, from, replyTo, subject, html, text, headers })); }; diff --git a/packages/rocketchat-i18n/i18n/en.i18n.json b/packages/rocketchat-i18n/i18n/en.i18n.json index 38db8d3d282c7..e640e506d888b 100644 --- a/packages/rocketchat-i18n/i18n/en.i18n.json +++ b/packages/rocketchat-i18n/i18n/en.i18n.json @@ -1232,6 +1232,7 @@ "email_style_label": "Email Style", "email_style_description": "Avoid nested selectors", "Email_verified": "Email verified", + "email_plain_text_only": "Send only plain text emails", "Emoji": "Emoji", "Emoji_provided_by_JoyPixels": "Emoji provided by JoyPixels", "EmojiCustomFilesystem": "Custom Emoji Filesystem", diff --git a/packages/rocketchat-i18n/i18n/pt-BR.i18n.json b/packages/rocketchat-i18n/i18n/pt-BR.i18n.json index f46f8f0530dbd..be6e4022459c1 100644 --- a/packages/rocketchat-i18n/i18n/pt-BR.i18n.json +++ b/packages/rocketchat-i18n/i18n/pt-BR.i18n.json @@ -1152,6 +1152,7 @@ "Email_subject": "Assunto", "email_style_label": "Estilo do Email", "email_style_description": "Evite seletores aninhados", + "email_plain_text_only": "Enviar emails apenas em texto puro", "Email_verified": "Email verificado", "Emoji": "Emoji", "EmojiCustomFilesystem": "Sistema de arquivos do emoji customizado",