Fix issue that would cause emails to be displayed incorrectly in certain email clients (#6267)

Fixes #6074
This commit is contained in:
Rijk van Zanten
2021-06-14 16:24:55 -04:00
committed by GitHub
parent 95f4b1c521
commit 36ecad783a
3 changed files with 9 additions and 0 deletions

View File

@@ -9,6 +9,7 @@ import logger from '../../logger';
import { AbstractServiceOptions, Accountability, SchemaOverview } from '../../types';
import getMailer from '../../mailer';
import { Transporter, SendMailOptions } from 'nodemailer';
import prettier from 'prettier';
const liquidEngine = new Liquid({
root: [path.resolve(env.EXTENSIONS_PATH, 'templates'), path.resolve(__dirname, 'templates')],
@@ -61,6 +62,11 @@ export class MailService {
html = await this.renderTemplate(template.name, templateData);
}
if (typeof html === 'string') {
// Some email clients start acting funky when line length exceeds 75 characters. See #6074
html = prettier.format(html as string, { parser: 'html', printWidth: 70, tabWidth: 0 });
}
try {
await this.mailer.sendMail({ ...emailOptions, from, html });
} catch (error) {