Last active
October 15, 2015 23:40
-
-
Save tonejito/1a50b4d8b181393ebf77 to your computer and use it in GitHub Desktop.
Send Logwatch email through MailGun API
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 | |
# /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