Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[NEW] Setting to only send plain text emails #16065

Merged
merged 5 commits into from
Feb 3, 2020
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions app/lib/server/startup/email.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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: true,
rodrigok marked this conversation as resolved.
Show resolved Hide resolved
},
});
});

Expand Down
14 changes: 12 additions & 2 deletions app/mailer/server/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
sampaiodiego marked this conversation as resolved.
Show resolved Hide resolved
}

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 = '';
Expand Down Expand Up @@ -103,7 +109,11 @@ export const sendNoWrap = ({ to, from, replyTo, subject, html, text, headers })
text = stripHtml(html);
}

Meteor.defer(() => Email.send({ to, from, replyTo, subject, html, text, headers }));
if (settings.get('email_plain_text_only')) {
html = undefined;
}

Meteor.defer(() => Email.send({ to, from, replyTo, subject, html, text, headers }));
};

export const send = ({ to, from, replyTo, subject, html, text, data, headers }) => sendNoWrap({ to, from, replyTo, subject: replace(subject, data), text: text ? replace(text, data) : stripHtml(replace(html, data)), html: wrap(html, data), headers });
Expand Down
1 change: 1 addition & 0 deletions packages/rocketchat-i18n/i18n/en.i18n.json
Original file line number Diff line number Diff line change
Expand Up @@ -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 <strong>JoyPixels</strong>",
"EmojiCustomFilesystem": "Custom Emoji Filesystem",
Expand Down
1 change: 1 addition & 0 deletions packages/rocketchat-i18n/i18n/pt-BR.i18n.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down