diff --git a/backend/.eslintignore b/backend/.eslintignore index 5498e0f..75cf428 100644 --- a/backend/.eslintignore +++ b/backend/.eslintignore @@ -1,2 +1,3 @@ build coverage +**/templates/** \ No newline at end of file diff --git a/backend/.eslintrc.js b/backend/.eslintrc.js index df1dca5..4e2558f 100644 --- a/backend/.eslintrc.js +++ b/backend/.eslintrc.js @@ -22,6 +22,7 @@ module.exports = { rules: { 'no-console': 'warn', '@typescript-eslint/no-unused-vars': ['error', { argsIgnorePattern: '^_' }], + '@typescript-eslint/ban-ts-comment': 'off', '@typescript-eslint/member-delimiter-style': [ 'error', { diff --git a/backend/src/applications/applications.controller.ts b/backend/src/applications/applications.controller.ts index 6aff017..f608e87 100644 --- a/backend/src/applications/applications.controller.ts +++ b/backend/src/applications/applications.controller.ts @@ -37,11 +37,13 @@ export class ApplicationsController { } // TODO: Consider fire and forget - await this.mailService.sendMail({ - subject: sendEmailToApplicantDto.subject, - text: sendEmailToApplicantDto.content, - to: applicantEmail, - }) + await this.mailService.sendMail( + { + subject: sendEmailToApplicantDto.subject, + to: applicantEmail, + }, + sendEmailToApplicantDto.content + ) return { status: 'success', diff --git a/backend/src/mailer/mailer.service.ts b/backend/src/mailer/mailer.service.ts index 02253dc..262aaea 100644 --- a/backend/src/mailer/mailer.service.ts +++ b/backend/src/mailer/mailer.service.ts @@ -3,6 +3,7 @@ import { Logger } from '@nestjs/common' import nodemailer, { SendMailOptions, Transporter } from 'nodemailer' import { ConfigService } from '../config/config.service' +import { htmlString } from './templates/standard' @Injectable() export class MailerService { @@ -27,8 +28,17 @@ export class MailerService { } sendMail = async ( - mailOptions: Omit + mailOptions: Omit, + message?: string ): Promise => { + if (message) { + return this.mailer.sendMail({ + from: this.config.get('mailConfig.temporarySender'), + to: mailOptions.to, + html: htmlString(message), + }) + } + return this.mailer.sendMail({ ...mailOptions, from: this.config.get('mailConfig.temporarySender'), diff --git a/backend/src/mailer/templates/standard.ts b/backend/src/mailer/templates/standard.ts new file mode 100644 index 0000000..f87a657 --- /dev/null +++ b/backend/src/mailer/templates/standard.ts @@ -0,0 +1,258 @@ +// @ts-nocheck +// tslint:disable + +export const htmlString = (message: string) => ` + + + + + + + + + + + + + + + + + + + + + + + + + `