Compare commits

...

2 Commits

Author SHA1 Message Date
Carina Wollendorfer 453ae71dae
Merge branch 'main' into fix/sendgrid-bypass-cleanup 2023-10-19 16:55:39 +02:00
CarinaWolli 02e4452cb8 remove sendgrid specific header if other host is used 2023-10-16 15:36:59 +02:00
3 changed files with 26 additions and 11 deletions

View File

@ -48,17 +48,7 @@ export default class BaseEmail {
const payload = this.getNodeMailerPayload();
const parseSubject = z.string().safeParse(payload?.subject);
const payloadWithUnEscapedSubject = {
headers: {
"X-SMTPAPI": JSON.stringify({
filters: {
bypass_list_management: {
settings: {
enable: 1,
},
},
},
}),
},
headers: this.getMailerOptions().headers,
...payload,
...(parseSubject.success && { subject: decodeHTML(parseSubject.data) }),
};
@ -84,6 +74,7 @@ export default class BaseEmail {
return {
transport: serverConfig.transport,
from: serverConfig.from,
headers: serverConfig.headers,
};
}

View File

@ -0,0 +1,21 @@
type EmailHostHeaders = {
[key: string]: {
[subKey: string]: string;
};
};
export function getAdditionalEmailHeaders(): EmailHostHeaders {
return {
"smtp.sendgrid.net": {
"X-SMTPAPI": JSON.stringify({
filters: {
bypass_list_management: {
settings: {
enable: 1,
},
},
},
}),
},
};
}

View File

@ -3,6 +3,8 @@ import type SMTPConnection from "nodemailer/lib/smtp-connection";
import { isENVDev } from "@calcom/lib/env";
import { getAdditionalEmailHeaders } from "./getAdditionalEmailHeaders";
function detectTransport(): SendmailTransport.Options | SMTPConnection.Options | string {
if (process.env.EMAIL_SERVER) {
return process.env.EMAIL_SERVER;
@ -41,4 +43,5 @@ function detectTransport(): SendmailTransport.Options | SMTPConnection.Options |
export const serverConfig = {
transport: detectTransport(),
from: process.env.EMAIL_FROM,
headers: getAdditionalEmailHeaders()[process.env.EMAIL_SERVER_HOST || ""] || undefined,
};