fix: add sendgrid-specific header only for SendGrid smtp server (#11932)
Co-authored-by: CarinaWolli <wollencarina@gmail.com>
This commit is contained in:
parent
9029c5b4c4
commit
7d09ccb0d7
|
@ -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,
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
@ -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,
|
||||
},
|
||||
},
|
||||
},
|
||||
}),
|
||||
},
|
||||
};
|
||||
}
|
|
@ -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,
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue
Block a user