feat: make MAIL FROM subdomain configurable via MAIL_FROM_SUBDOMAIN env var

This commit is contained in:
Tania Sanz
2026-05-12 20:35:53 +02:00
parent 715961c007
commit e0bf0f628a
7 changed files with 36 additions and 10 deletions
+6
View File
@@ -45,6 +45,12 @@ export const AWS_SES_REGION = validateEnv('AWS_SES_REGION');
export const AWS_SES_ACCESS_KEY_ID = validateEnv('AWS_SES_ACCESS_KEY_ID');
export const AWS_SES_SECRET_ACCESS_KEY = validateEnv('AWS_SES_SECRET_ACCESS_KEY');
// Custom MAIL FROM subdomain used to construct `<subdomain>.<your-domain>`
// when a domain is added. Defaults to `plunk`. Override when `plunk.<your-domain>`
// is already used for something else (e.g. a CDN), since the MAIL FROM hostname
// needs MX + TXT records that can't coexist with a CNAME.
export const MAIL_FROM_SUBDOMAIN = validateEnv('MAIL_FROM_SUBDOMAIN', '').trim() || 'plunk';
// Email Processing Rate Limit (optional override)
// If not set, will automatically fetch from AWS SES account quota
// Set this to override AWS quota (useful for setting lower limits or testing)
+2
View File
@@ -8,6 +8,7 @@ import {
GITHUB_OAUTH_ENABLED,
GOOGLE_OAUTH_ENABLED,
LANDING_URI,
MAIL_FROM_SUBDOMAIN,
NODE_ENV,
S3_ENABLED,
SMTP_DOMAIN,
@@ -62,6 +63,7 @@ export class Config {
},
aws: {
sesRegion: AWS_SES_REGION,
mailFromSubdomain: MAIL_FROM_SUBDOMAIN,
},
});
}
+6 -2
View File
@@ -6,6 +6,7 @@ import {
AWS_SES_REGION,
AWS_SES_SECRET_ACCESS_KEY,
DASHBOARD_URI,
MAIL_FROM_SUBDOMAIN,
SES_CONFIGURATION_SET,
SES_CONFIGURATION_SET_NO_TRACKING,
TRACKING_TOGGLE_ENABLED,
@@ -250,10 +251,13 @@ export const verifyDomain = async (domain: string): Promise<string[]> => {
// Verify DKIM for the domain
const DKIM = await ses.verifyDomainDkim({Domain: domain});
// Set custom MAIL FROM domain (plunk.yourdomain.com)
// Set custom MAIL FROM domain. The subdomain defaults to `plunk` and can be
// overridden via the MAIL_FROM_SUBDOMAIN env var — useful when `plunk.<domain>`
// is already in use for something else (e.g., a CNAME to a CDN), since the
// MAIL FROM subdomain needs MX + TXT records that conflict with a CNAME.
await ses.setIdentityMailFromDomain({
Identity: domain,
MailFromDomain: `plunk.${domain}`,
MailFromDomain: `${MAIL_FROM_SUBDOMAIN}.${domain}`,
});
return DKIM.DkimTokens ?? [];
+10 -8
View File
@@ -335,6 +335,8 @@ export function DomainsSettings({projectId}: DomainsSettingsProps) {
<div className="space-y-4">
{domains.map(domain => {
const status = getDomainStatus(domain);
const mailFromSubdomain = config?.aws?.mailFromSubdomain ?? 'plunk';
const mailFromHost = `${mailFromSubdomain}.${domain.domain}`;
return (
<div key={domain.id} className="border border-neutral-200 rounded-lg p-4">
<div className="flex items-center justify-between mb-3">
@@ -494,8 +496,8 @@ export function DomainsSettings({projectId}: DomainsSettingsProps) {
</Badge>
</div>
<p className="text-xs text-neutral-600 mb-2">
Set up a custom MAIL FROM domain (plunk.{domain.domain}) to improve deliverability and
handle bounces/complaints.
Set up a custom MAIL FROM domain ({mailFromHost}) to improve deliverability and handle
bounces/complaints.
</p>
<div className="overflow-x-auto">
@@ -522,16 +524,16 @@ export function DomainsSettings({projectId}: DomainsSettingsProps) {
<td className="py-3 px-3">
<div className="flex items-center gap-2">
<code className="text-xs font-mono text-neutral-700 break-all flex-1">
plunk.{domain.domain}
{mailFromHost}
</code>
<Button
variant="ghost"
size="sm"
onClick={() => handleCopyToken(`plunk.${domain.domain}`, 3000)}
onClick={() => handleCopyToken(mailFromHost, 3000)}
className="shrink-0 h-6 w-6 p-0 overflow-hidden"
>
<AnimatedCopyIcon
isCopied={copiedToken === `plunk.${domain.domain}-3000`}
isCopied={copiedToken === `${mailFromHost}-3000`}
/>
</Button>
</div>
@@ -571,16 +573,16 @@ export function DomainsSettings({projectId}: DomainsSettingsProps) {
<td className="py-3 px-3">
<div className="flex items-center gap-2">
<code className="text-xs font-mono text-neutral-700 break-all flex-1">
plunk.{domain.domain}
{mailFromHost}
</code>
<Button
variant="ghost"
size="sm"
onClick={() => handleCopyToken(`plunk.${domain.domain}`, 3001)}
onClick={() => handleCopyToken(mailFromHost, 3001)}
className="shrink-0 h-6 w-6 p-0 overflow-hidden"
>
<AnimatedCopyIcon
isCopied={copiedToken === `plunk.${domain.domain}-3001`}
isCopied={copiedToken === `${mailFromHost}-3001`}
/>
</Button>
</div>
+1
View File
@@ -21,6 +21,7 @@ export interface ConfigResponse {
};
aws: {
sesRegion: string;
mailFromSubdomain: string;
};
}