Edits history of script submission #22352 for ' send an email with aws ses (aws-ses)'

  • bun
    One script reply has been approved by the moderators
    Ap­pro­ved
    import { SESClient, SendEmailCommand } from "@aws-sdk/client-ses@3";
    
    // Create sendEmail params
    type Aws = {
      awsAccessKeyId: string;
      awsSecretAccessKey: string;
      region: string;
    };
    export async function main(
      toAddresses: string[],
      htmlData: string,
      textData: string,
      subject: string,
      source: string,
      credentials: Aws,
    ) {
      var params = {
        Destination: {
          ToAddresses: toAddresses,
        },
        Message: {
          Body: {
            Html: {
              Charset: "UTF-8",
              Data: htmlData,
            },
            Text: {
              Charset: "UTF-8",
              Data: textData,
            },
          },
          Subject: {
            Charset: "UTF-8",
            Data: subject,
          },
        },
        Source: source /* required */,
      };
    
      // Create the SES service object
      const ses = new SESClient({
        credentials: {
          accessKeyId: credentials.awsAccessKeyId,
          secretAccessKey: credentials.awsSecretAccessKey,
        },
        region: credentials.region,
      });
      return await ses.send(new SendEmailCommand(params));
    }
    

    Submitted by hugo989 17 days ago