diff --git a/src/config/configuration.interface.ts b/src/config/configuration.interface.ts index 193c0dab1..53ba13859 100644 --- a/src/config/configuration.interface.ts +++ b/src/config/configuration.interface.ts @@ -29,7 +29,11 @@ export interface Configuration { email: { name: string; from: string; - ses?: boolean; + ses?: { + accessKeyId: string; + secretAccessKey: string; + region: string; + }; transport?: { host: string; port: number; diff --git a/src/config/configuration.ts b/src/config/configuration.ts index 32bd57fd0..f86da5cef 100644 --- a/src/config/configuration.ts +++ b/src/config/configuration.ts @@ -33,7 +33,11 @@ const configuration: Configuration = { email: { name: process.env.EMAIL_NAME ?? 'Staart', from: process.env.EMAIL_FROM ?? '', - ses: !!process.env.EMAIL_SES, + ses: { + accessKeyId: process.env.EMAIL_SES_ACCESS_KEY_ID ?? '', + secretAccessKey: process.env.EMAIL_SES_SECRET_ACCESS_KEY ?? '', + region: process.env.EMAIL_SES_REGION ?? '', + }, transport: { host: process.env.EMAIL_HOST ?? '', port: int(process.env.EMAIL_PORT, 587), diff --git a/src/providers/mail/mail.service.ts b/src/providers/mail/mail.service.ts index 0765b9111..ede3ed746 100644 --- a/src/providers/mail/mail.service.ts +++ b/src/providers/mail/mail.service.ts @@ -23,10 +23,14 @@ export class MailService { constructor(private configService: ConfigService) { this.config = this.configService.get('email'); - console.log(this.config); - if (this.config.ses) + if (this.config.ses?.accessKeyId) this.transport = nodemailer.createTransport({ - SES: new SES({ apiVersion: '2010-12-01' }), + SES: new SES({ + apiVersion: '2010-12-01', + accessKeyId: this.config.ses.accessKeyId, + secretAccessKey: this.config.ses.secretAccessKey, + region: this.config.ses.region, + }), } as SESTransport.Options); else this.transport = nodemailer.createTransport(this.config.transport); } @@ -48,6 +52,7 @@ export class MailService { `Mail to ${options.to} failed, retrying (${error.retriesLeft} attempts left)`, error.name, ); + console.log(error); }, }, ),