-
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.
- Loading branch information
1 parent
cc2d10b
commit 6241871
Showing
5 changed files
with
108 additions
and
2 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
import { Injectable } from "@nestjs/common"; | ||
import { ConfigService } from "@nestjs/config"; | ||
import { SESClient, SendEmailCommand } from "@aws-sdk/client-ses"; | ||
|
||
@Injectable() | ||
export class EmailService { | ||
constructor(private readonly configService: ConfigService) {} | ||
|
||
async send(email: string) { | ||
const client = new SESClient({ | ||
region: this.configService.getOrThrow('AWS_REGION'), | ||
credentials: { | ||
accessKeyId: this.configService.getOrThrow('AWS_ACCESS_KEY_ID'), | ||
secretAccessKey: this.configService.getOrThrow('AWS_SECRET_KEY_ID'), | ||
}, | ||
}); | ||
|
||
const input = { | ||
"Destination": { | ||
"BccAddresses": [], | ||
"CcAddresses": [], | ||
"ToAddresses": [email] | ||
}, | ||
"Message": { | ||
"Body": { | ||
"Html": { | ||
"Charset": "UTF-8", | ||
"Data": "This message body contains HTML formatting. It can, for example, contain links like this one: <a class=\"ulink\" href=\"http://docs.aws.amazon.com/ses/latest/DeveloperGuide\" target=\"_blank\">Amazon SES Developer Guide</a>." | ||
}, | ||
"Text": { | ||
"Charset": "UTF-8", | ||
"Data": "This is the message body in text format." | ||
} | ||
}, | ||
"Subject": { | ||
"Charset": "UTF-8", | ||
"Data": "Test email" | ||
} | ||
}, | ||
"ReplyToAddresses": ["[email protected]"], | ||
"Source": "[email protected]", | ||
}; | ||
|
||
const command = new SendEmailCommand(input); | ||
return await client.send(command); | ||
} | ||
} |