Skip to content

Instantly share code, notes, and snippets.

@tonejito
Last active October 15, 2015 23:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tonejito/1a50b4d8b181393ebf77 to your computer and use it in GitHub Desktop.
Save tonejito/1a50b4d8b181393ebf77 to your computer and use it in GitHub Desktop.
Send Logwatch email through MailGun API
#!/bin/bash
# /usr/local/sbin/mailgun
# Send Logwatch email through MailGun API
# Replace the key, endpoint and "to" email with your own values
# Check the example values here:
# https://documentation.mailgun.com/quickstart-sending.html#send-via-api
# https://help.mailgun.com/hc/en-us/articles/202464990-How-do-I-start-sending-email-
HOSTNAME=/bin/hostname
UNAME=/bin/uname
CURL=/usr/bin/curl
FROM="Logwatch <root+logwatch@`$HOSTNAME`>"
TO="sysadmin@example.com"
SUBJECT="Logwatch for `$HOSTNAME` (`$UNAME -s`)"
MIME_TYPE="text/plain"
API_KEY=key-00000000000000000000000000000000
API_ENDPOINT="https://api.mailgun.net/v3/example.com/messages"
$CURL -sk \
-F from="$FROM" \
-F to="$TO" \
-F subject="$SUBJECT" \
-F text="<-;type=$MIME_TYPE" \
--user "api:$API_KEY" \
$API_ENDPOINT \
> /dev/null ;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment