Skip to content

Instantly share code, notes, and snippets.

@joglomedia
Forked from johnnydecimal/amazon-ses.sh
Created October 25, 2024 13:27
Show Gist options
  • Save joglomedia/ff1aa12e2b711adb91a3657004b5b25b to your computer and use it in GitHub Desktop.
Save joglomedia/ff1aa12e2b711adb91a3657004b5b25b 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
@joglomedia
Copy link
Author

recipients=$(cut -d= -f1 ./recipients.txt)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment