Skip to content

Instantly share code, notes, and snippets.

@johnnydecimal
Last active October 25, 2024 13:27
Show Gist options
  • Save johnnydecimal/e7b1a03e26b79239363b5ddebef4f3c1 to your computer and use it in GitHub Desktop.
Save johnnydecimal/e7b1a03e26b79239363b5ddebef4f3c1 to your computer and use it in GitHub Desktop.
Amazon SES mail sending script
#!/bin/bash
## ** UPDATE PER-MESSAGE **
message_body=$(<message.txt)
subject="The Quarterly, 1st ed. 2024-06 [D85.23.13]"
# sender
sender="Johnny ‘Decimal’ Noble <[email protected]>"
body="$message_body"
###########################################################
region="ap-southeast-2"
# List of recipients, one per line. Defaults to SES mailbox simulator addresses (https://docs.aws.amazon.com/ses/latest/dg/send-an-email-from-console.html#send-email-simulator-how-to-use)
recipients=(
# always leave these tests here
"[email protected]"
"[email protected]"
"[email protected]"
# actual recipients here
)
# Send an email to each recipient
# Iterate through the list of recipients.
# Invoke the AWS SES SendEmail operation with a single recipient defined in the Destination
for recipient in "${recipients[@]}"; do
echo sending to "$recipient"
aws sesv2 send-email \
--from-email-address "$sender" \
--destination "ToAddresses=$recipient" \
--content "Simple={Subject={Data='$subject',Charset='UTF-8'},Body={Text={Data='$body',Charset='UTF-8'}}}" \
--region "$region"
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment