summaryrefslogtreecommitdiff
path: root/bin/configure-ssmtp.sh
blob: 361bd119fac0814b02c6260a410c89187ed11688 (plain)
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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
#!/bin/bash

if [ "$EUID" != "0" ]; then
    echo "Run as root"
    exit 1
fi

if [ -z "$AWS_ACCESS_KEY_ID" ]; then
    echo "Export AWS_ACCESS_KEY_ID"
    exit 1
fi

if [ -z "$AWS_SECRET_ACCESS_KEY" ]; then
    echo "Export AWS_SECRET_ACCESS_KEY"
    exit 1
fi

if [ ! -x "./ses-password-convert.py" ]; then
    curl -O https://code.crute.me/mcrute/dotfiles/plain/bin/ses-password-convert.py
    chmod +x ses-password-convert.py
fi

USER=mike
DOMAIN=crute.us

cat > /etc/ssmtp/ssmtp.conf <<EOF
#
# Config file for sSMTP sendmail
#
# The person who gets all mail for userids < 1000
# Make this empty to disable rewriting.
root=$USER@$DOMAIN

# The place where the mail goes. The actual machine name is required no 
# MX records are consulted. Commonly mailhosts are named mail.domain.com
mailhub=email-smtp.us-west-2.amazonaws.com:587

# Where will the mail seem to come from?
rewriteDomain=crute.us

# The full hostname
hostname=$(hostname -f)

# Use SSL/TLS before starting negotiation
UseTLS=Yes
UseSTARTTLS=Yes

# Username/Password
AuthUser=$AWS_ACCESS_KEY_ID
AuthPass=$(./ses-password-convert.py $AWS_SECRET_ACCESS_KEY)

# Are users allowed to set their own From: address?
# YES - Allow the user to specify their own From: address
# NO - Use the system generated From: address
FromLineOverride=YES
EOF

rm ses-password-convert.py