Last active
February 15, 2018 10:20
-
-
Save ypchen/5b1b1af9750cb54b6e1e88fe9a91d2f7 to your computer and use it in GitHub Desktop.
send a message to Mailgun
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 | |
# default | |
if [ -z ${CURL+x} ]; then | |
CURL="/usr/bin/curl" | |
fi | |
# mg_domain, api_key, MSG_SUBJ_PREFIX, MSG_FROM_EMAIL, & CURL if necessary | |
CONF="${HOME}/.Mailgun.conf" | |
source ${CONF} | |
if [ -z ${to_email+x} ]; then | |
to_email="${1}" | |
fi | |
if [ -z ${MSG_SUBJ_PREFIX+x} ]; then | |
MSG_SUBJ_PREFIX="" | |
fi | |
if [ -z ${subject+x} ]; then | |
subject="${MSG_SUBJ_PREFIX}${2}" | |
fi | |
if [ -z ${text+x} ]; then | |
text="${3}" | |
fi | |
if [ -z "${4}" ]; then | |
from_email="${MSG_FROM_EMAIL}" | |
else | |
from_email="${4}" | |
fi | |
${CURL} -s --user "api:${api_key}" \ | |
https://api.mailgun.net/v3/${mg_domain}/messages \ | |
-F from="${from_email}" \ | |
-F to="${to_email}" \ | |
-F subject="${subject}" \ | |
-F text="${text}" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment