Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat : Added support for different email service provider. #746

Open
wants to merge 2 commits into
base: archive/develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
feat : Added support for different email service provider.
Signed-off-by: Ganesh Nawle <ganesh.nawle@ayanworks.com>
  • Loading branch information
ganeshawle25 committed Jun 3, 2024
commit 7f18fa71fdbf708f74761644caf99b190c831874
14 changes: 9 additions & 5 deletions libs/common/src/aws-ses-helper-file.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,21 +8,25 @@ dotenv.config();

export const sendWithSES = async (emailDto: EmailDto): Promise<boolean> => {
const awsSES = new AWS.SES({
apiVersion: '2010-12-01',
apiVersion: process.env.AWS_SES_VERSION,
region: process.env.AWS_SES_REGION,
credentials: {
accessKeyId: process.env.AWS_SES_ACCESS_KEY,
secretAccessKey: process.env.AWS_SES_SECRET_KEY
}
},
endpoint: `https://email.${process.env.AWS_SES_REGION}.amazonaws.com`
});

const transporter = nodemailer.createTransport({
SES: awsSES
SES: awsSES,
secure: true
});

try {
return await transporter
.sendMail({
from: emailDto.emailFrom,
to: emailDto.emailTo, //list of receivers
to: emailDto.emailTo,
subject: emailDto.emailSubject,
text: emailDto.emailText,
html: emailDto.emailHtml,
Expand All @@ -34,4 +38,4 @@ export const sendWithSES = async (emailDto: EmailDto): Promise<boolean> => {
Logger.error('Error while sending email with Amazon SES', error);
return false;
}
};
};
1 change: 0 additions & 1 deletion libs/common/src/email.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ export class EmailService {
throw new Error('Email provider is not set in environment variables. Please provide email service provider property.');
}
try {
this.logger.debug(`Email Provider is ::::::::${provider}`);
switch (provider) {
case 'ses':
result = await sendWithSES(emailDto);
Expand Down