// AWS offers an email forwarding service called SES.
// To start, register with AWS and get your
// access key ID and secret access key.
// The AWS SES library can access your credentials via your environment.
// Visit the SES console and verify the hosts that you'll
// send emails from and the addresses you'll be testing.
// Next, install the SES library (npm install @aws-sdk/client-ses).
// You can use the code below to send a test message.
const {SESClient,SendEmailCommand} = require("@aws-sdk/client-ses");
const sesClient = new SESClient({ region: 'YOUR REGION' });
const createMessage = ({to, from, subject, text}) => {
return new SendEmailCommand({
Source: from,
Destination: {ToAddresses: [to]},
Message: {
Subject: { Data: subject },
Body: { Text: { Data: text}},
},
});
};
const message = createMessage({
to: 'verified address',
from: 'verified address',
subject: 'test message',
text: `
This is a test message.
`});
sesClient.send(message)
.then(result=>console.log(`Delivered. Message ID is ${result.MessageId} .`))
.catch(err=>console.log(err?.Error?.message || err))
// https://sean.brunnock.com 12/2022