Skip to content

The open alternative to Salesforce, designed for AI.

Use a twenty-bounce MAIL FROM subdomain for new sending domains (#25995)

neo7738efc54a831c0
diff --git a/packages/twenty-server/src/engine/core-modules/emailing-domain/drivers/aws-ses/constants/aws-ses-mail-from-subdomain.constant.ts b/packages/twenty-server/src/engine/core-modules/emailing-domain/drivers/aws-ses/constants/aws-ses-mail-from-subdomain.constant.ts
index b01807c9cff..828d8278b71 100644
--- a/packages/twenty-server/src/engine/core-modules/emailing-domain/drivers/aws-ses/constants/aws-ses-mail-from-subdomain.constant.ts
+++ b/packages/twenty-server/src/engine/core-modules/emailing-domain/drivers/aws-ses/constants/aws-ses-mail-from-subdomain.constant.ts
@@ -1 +1 @@
-export const AWS_SES_MAIL_FROM_SUBDOMAIN = 'bounce';
+export const AWS_SES_MAIL_FROM_SUBDOMAIN = 'twenty-bounce';
diff --git a/packages/twenty-server/src/engine/core-modules/emailing-domain/drivers/aws-ses/services/aws-ses-driver.service.ts b/packages/twenty-server/src/engine/core-modules/emailing-domain/drivers/aws-ses/services/aws-ses-driver.service.ts
index 94367e5acc6..b374bda78b5 100644
--- a/packages/twenty-server/src/engine/core-modules/emailing-domain/drivers/aws-ses/services/aws-ses-driver.service.ts
+++ b/packages/twenty-server/src/engine/core-modules/emailing-domain/drivers/aws-ses/services/aws-ses-driver.service.ts
@@ -105,6 +105,7 @@ export class AwsSesDriver implements EmailingDomainDriverInterface {
const verificationRecords = buildAwsSesVerificationRecords({
domain: input.domain,
dkimTokens: identityResponse.DkimAttributes?.Tokens ?? [],
+ mailFromDomain: identityResponse.MailFromAttributes?.MailFromDomain,
region: this.config.region,
});
@@ -285,6 +286,7 @@ export class AwsSesDriver implements EmailingDomainDriverInterface {
const verificationRecords = buildAwsSesVerificationRecords({
domain,
dkimTokens: existingIdentity.DkimAttributes?.Tokens ?? [],
+ mailFromDomain: existingIdentity.MailFromAttributes?.MailFromDomain,
region: this.config.region,
});
diff --git a/packages/twenty-server/src/engine/core-modules/emailing-domain/drivers/aws-ses/utils/__tests__/build-aws-ses-verification-records.util.spec.ts b/packages/twenty-server/src/engine/core-modules/emailing-domain/drivers/aws-ses/utils/__tests__/build-aws-ses-verification-records.util.spec.ts
index e3cf39d2c3d..cbbadd5eeb1 100644
--- a/packages/twenty-server/src/engine/core-modules/emailing-domain/drivers/aws-ses/utils/__tests__/build-aws-ses-verification-records.util.spec.ts
+++ b/packages/twenty-server/src/engine/core-modules/emailing-domain/drivers/aws-ses/utils/__tests__/build-aws-ses-verification-records.util.spec.ts
@@ -37,7 +37,7 @@ describe('buildAwsSesVerificationRecords', () => {
expect(records.filter((record) => record.type === 'MX')).toEqual([
{
type: 'MX',
- key: 'bounce.acme.com',
+ key: 'twenty-bounce.acme.com',
value: 'feedback-smtp.us-east-1.amazonses.com',
priority: 10,
},
@@ -54,7 +54,7 @@ describe('buildAwsSesVerificationRecords', () => {
expect(records.filter((record) => record.type === 'TXT')).toEqual([
{
type: 'TXT',
- key: 'bounce.acme.com',
+ key: 'twenty-bounce.acme.com',
value: 'v=spf1 include:amazonses.com ~all',
},
]);
@@ -69,4 +69,18 @@ describe('buildAwsSesVerificationRecords', () => {
expect(records).toHaveLength(2);
});
+
+ it('should keep the MAIL FROM subdomain already registered in SES for the domain', () => {
+ const records = buildAwsSesVerificationRecords({
+ domain: 'acme.com',
+ dkimTokens: [],
+ mailFromDomain: 'bounce.acme.com',
+ region: 'eu-west-3',
+ });
+
+ expect(records.map((record) => record.key)).toEqual([
+ 'bounce.acme.com',
+ 'bounce.acme.com',
+ ]);
+ });
});
diff --git a/packages/twenty-server/src/engine/core-modules/emailing-domain/drivers/aws-ses/utils/build-aws-ses-verification-records.util.ts b/packages/twenty-server/src/engine/core-modules/emailing-domain/drivers/aws-ses/utils/build-aws-ses-verification-records.util.ts
index 15cb9a0b38f..68f3a39b736 100644
--- a/packages/twenty-server/src/engine/core-modules/emailing-domain/drivers/aws-ses/utils/build-aws-ses-verification-records.util.ts
+++ b/packages/twenty-server/src/engine/core-modules/emailing-domain/drivers/aws-ses/utils/build-aws-ses-verification-records.util.ts
@@ -4,6 +4,7 @@ import { type VerificationRecord } from 'src/engine/core-modules/emailing-domain
type BuildAwsSesVerificationRecordsArgs = {
domain: string;
dkimTokens: string[];
+ mailFromDomain?: string;
region: string;
};
@@ -13,10 +14,9 @@ const MAIL_FROM_SPF_VALUE = 'v=spf1 include:amazonses.com ~all';
export const buildAwsSesVerificationRecords = ({
domain,
dkimTokens,
+ mailFromDomain = `${AWS_SES_MAIL_FROM_SUBDOMAIN}.${domain}`,
region,
}: BuildAwsSesVerificationRecordsArgs): VerificationRecord[] => {
- const mailFromDomain = `${AWS_SES_MAIL_FROM_SUBDOMAIN}.${domain}`;
-
const dkimRecords: VerificationRecord[] = dkimTokens.map((token) => ({
type: 'CNAME',
key: `${token}._domainkey.${domain}`,