Skip to content

Instantly share code, notes, and snippets.

@markymarkus
Created February 9, 2021 11:18
Show Gist options
  • Save markymarkus/aea307cec94578d99356e032c5c74dda to your computer and use it in GitHub Desktop.
Save markymarkus/aea307cec94578d99356e032c5c74dda to your computer and use it in GitHub Desktop.
Amazon SES curl
#!/bin/bash
TO="USER@XXXX.XXX"
FROM="SENDER@XXXX.XXX"
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