-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[feat] AWS SES 마이그레이션 및 오류 수정
- Loading branch information
Showing
12 changed files
with
227 additions
and
2,634 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import { Module } from '@nestjs/common'; | ||
import { EmailService } from './email.service'; | ||
|
||
@Module({ providers: [EmailService], exports: [EmailService] }) | ||
export class EmailModule {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
import * as AWS from 'aws-sdk'; | ||
import * as ejs from 'ejs'; | ||
|
||
export class EmailService { | ||
private readonly ses: AWS.SES = new AWS.SES({ | ||
region: process.env.AWS_REGION, | ||
credentials: { | ||
accessKeyId: process.env.AWS_ACCESS_KEY_ID, | ||
secretAccessKey: process.env.AWS_SECRET_ACCESS_KEY, | ||
}, | ||
}); | ||
|
||
async sendEmail(email: string, title: string, html: string) { | ||
const sendEmailParams: AWS.SES.SendEmailRequest = { | ||
Destination: { | ||
CcAddresses: [], | ||
ToAddresses: [email], // 받을 사람의 이메일 | ||
}, | ||
Message: { | ||
Body: { | ||
Html: { | ||
Charset: 'UTF-8', | ||
Data: html, | ||
}, | ||
}, | ||
Subject: { | ||
Charset: 'UTF-8', | ||
Data: title, | ||
}, | ||
}, | ||
Source: '[email protected]', | ||
ReplyToAddresses: [], | ||
}; | ||
const result = await this.ses.sendEmail(sendEmailParams).promise(); | ||
return result; | ||
} | ||
|
||
async template(ejsFileName: string, data: object) { | ||
const path = __dirname + '/../../views/' + ejsFileName; // ejs 파일 경로 | ||
|
||
let html; | ||
await ejs.renderFile(path, data, async (err, res) => { | ||
if (!err) { | ||
html = res; | ||
} | ||
}); | ||
return html; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters