Created
February 9, 2021 11:18
-
-
Save markymarkus/aea307cec94578d99356e032c5c74dda to your computer and use it in GitHub Desktop.
Amazon SES curl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
TO="[email protected]" | |
FROM="[email protected]" | |
SUBJECT="Test mail" | |
MESSAGE="liam tseT" | |
date="$(date +"%a, %d %b %Y %H:%M:%S %Z")" | |
priv_key="AWS_SECRET_KEY" | |
access_key="AWS_ACCESS_KEY" | |
signature="$(echo -n "$date" | openssl dgst -sha256 -hmac "$priv_key" -binary | base64 -b 0)" | |
auth_header="X-Amzn-Authorization: AWS3-HTTPS AWSAccessKeyId=$access_key, Algorithm=HmacSHA256, Signature=$signature" | |
endpoint="https://email.eu-west-1.amazonaws.com/" | |
action="Action=SendEmail" | |
source="Source=$FROM" | |
to="Destination.ToAddresses.member.1=$TO" | |
subject="Message.Subject.Data=$SUBJECT" | |
message="Message.Body.Text.Data=$MESSAGE" | |
curl -v -X POST -H "Date: $date" -H "$auth_header" --data-urlencode "$message" --data-urlencode "$to" --data-urlencode "$source" --data-urlencode "$action" --data-urlencode "$subject" "$endpoint" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment