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