-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsend-ses
More file actions
executable file
·39 lines (35 loc) · 911 Bytes
/
send-ses
File metadata and controls
executable file
·39 lines (35 loc) · 911 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#!/bin/bash
# Category: system
# Description: Send email via AWS SES
#
# 1. Create a file like:
# ~/.aws/credentials
#[email]
#aws_access_key_id=
#aws_secret_access_key=
#
#
# 2. Need to verify email address in AWS console *for that particular region*
#
EMAIL=$ADMIN_EMAIL
REGION=us-east-1
SUBJECT=$1
BODY=$2
if [ -z "$EMAIL" ]; then
echo "ERROR: ADMIN_EMAIL env variable not defined" >&2
exit 1
fi
# This script is called from cron jobs, which have a minimal PATH.
# Hardcoded paths ensure aws is found regardless of the environment.
AWS_CMD=""
for path in /snap/bin/aws /usr/local/bin/aws /usr/bin/aws /opt/homebrew/bin/aws; do
if [ -x "$path" ]; then
AWS_CMD="$path"
break
fi
done
if [ -z "$AWS_CMD" ]; then
echo "ERROR: aws command not found" >&2
exit 1
fi
$AWS_CMD --profile email ses send-email --from $EMAIL --to $EMAIL --region $REGION --text "$BODY" --subject "$SUBJECT" >>$HOME/.ses.log