Verify email domain before sending emails
This commit is contained in:
@@ -5,6 +5,7 @@ import {prisma} from '../database/prisma.js';
|
||||
import {HttpException} from '../exceptions/index.js';
|
||||
import {buildEmailFieldsUpdate} from '../utils/modelUpdate.js';
|
||||
|
||||
import {DomainService} from './DomainService.js';
|
||||
import {EmailService} from './EmailService.js';
|
||||
import {QueueService} from './QueueService.js';
|
||||
import {type SegmentFilter, SegmentService} from './SegmentService.js';
|
||||
@@ -650,6 +651,9 @@ export class CampaignService {
|
||||
throw new HttpException(403, 'Test emails can only be sent to project members');
|
||||
}
|
||||
|
||||
// Verify domain is registered and verified before sending
|
||||
await DomainService.verifyEmailDomain(campaign.from, projectId);
|
||||
|
||||
// Get project to validate from address
|
||||
const project = await prisma.project.findUnique({
|
||||
where: {id: projectId},
|
||||
|
||||
@@ -7,6 +7,7 @@ import {prisma} from '../database/prisma.js';
|
||||
import {HttpException} from '../exceptions/index.js';
|
||||
|
||||
import {BillingLimitService} from './BillingLimitService.js';
|
||||
import {DomainService} from './DomainService.js';
|
||||
import {QueueService} from './QueueService.js';
|
||||
import {sendRawEmail} from './SESService.js';
|
||||
|
||||
@@ -310,6 +311,10 @@ export class EmailService {
|
||||
}
|
||||
|
||||
try {
|
||||
// Verify domain is registered and verified before sending
|
||||
// This ensures all emails (transactional, campaign, workflow) use verified domains
|
||||
await DomainService.verifyEmailDomain(email.from, email.projectId);
|
||||
|
||||
// Update status to sending
|
||||
await prisma.email.update({
|
||||
where: {id: emailId},
|
||||
|
||||
Reference in New Issue
Block a user