mirror of
https://github.com/talgo-cloud/Mailer.git
synced 2026-03-09 07:28:17 -07:00
First
This commit is contained in:
commit
c3788cc413
14 changed files with 4371 additions and 0 deletions
31
src/mailer.js
Normal file
31
src/mailer.js
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
// Load the AWS SDK for Node.js
|
||||
import { SESv2Client, SendEmailCommand } from "@aws-sdk/client-sesv2"; // ES Modules import
|
||||
const client = new SESv2Client();
|
||||
|
||||
export default function sendEmail(mailData) {
|
||||
const input = { // SendEmailRequest
|
||||
FromEmailAddress: mailData.from,
|
||||
Destination: { // Destination
|
||||
ToAddresses: [ // EmailAddressList
|
||||
mailData.to,
|
||||
],
|
||||
},
|
||||
Content: { // EmailContent
|
||||
Simple: { // Message
|
||||
Subject: { // Content
|
||||
Data: mailData.subject, // required
|
||||
Charset: 'utf-8',
|
||||
},
|
||||
Body: { // Body
|
||||
Html: {
|
||||
Data: mailData.body, // required
|
||||
Charset: 'utf-8',
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
const command = new SendEmailCommand(input);
|
||||
return client.send(command);
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue