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

@@ -125,6 +125,7 @@
"otplib": "^12.0.1",
"pino": "^6.11.3",
"pino-colada": "^2.1.0",
"prettier": "^2.3.1",
"qs": "^6.9.4",
"rate-limiter-flexible": "^2.2.2",
"resolve-cwd": "^3.0.0",

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) {

2
package-lock.json generated
View File

@@ -116,6 +116,7 @@
"otplib": "^12.0.1",
"pino": "^6.11.3",
"pino-colada": "^2.1.0",
"prettier": "^2.3.1",
"qs": "^6.9.4",
"rate-limiter-flexible": "^2.2.2",
"resolve-cwd": "^3.0.0",
@@ -72858,6 +72859,7 @@
"pg": "^8.6.0",
"pino": "^6.11.3",
"pino-colada": "^2.1.0",
"prettier": "*",
"qs": "^6.9.4",
"rate-limiter-flexible": "^2.2.2",
"resolve-cwd": "^3.0.0",