committed by
GitHub
11 changed files with 108 additions and 57 deletions
@ -67,6 +67,13 @@ rocketchatalert="off" |
|||
rocketchatwebhook="webhook" |
|||
rocketchattoken="" |
|||
|
|||
# Sendgrid Email Alerts | https://docs.linuxgsm.com/alerts/sendgrid |
|||
sendgridalert="off" |
|||
sendgridtoken="accesstoken" |
|||
sendgriddomain="example.com" |
|||
sendgridemailfrom="[email protected]" |
|||
sendgridemail="[email protected]" |
|||
|
|||
# Slack Alerts | https://docs.linuxgsm.com/alerts/slack |
|||
slackalert="off" |
|||
slackwebhook="webhook" |
|||
|
@ -0,0 +1,23 @@ |
|||
#!/bin/bash |
|||
# LinuxGSM alert_sendgrid.sh function |
|||
# Author: Daniel Gibbs |
|||
# Website: https://linuxgsm.com |
|||
# Description: Sends SendGrid Email alert. |
|||
|
|||
functionselfname="$(basename "$(readlink -f "${BASH_SOURCE[0]}")")" |
|||
|
|||
fn_print_dots "Sending Email alert: SendGrid: ${email}" |
|||
|
|||
sendgridsend=$(curl -s --request POST \ |
|||
--url https://api.sendgrid.com/v3/mail/send \ |
|||
--header "Authorization: Bearer ${sendgridtoken}" \ |
|||
--header 'Content-Type: application/json' \ |
|||
--data '{"personalizations": [{"to": [{"email": ${sendgridemail}"}]}],"from": {"email": "${sendgridemailfrom}"},"subject": "${alertemoji} ${alertsubject} ${alertemoji}","content": [{"type": "text/plain", "value": "$(cat "${alertlog}")"}]}') |
|||
|
|||
if [ -z "${sendgridsend}" ]; then |
|||
fn_print_fail_nl "Sending Email alert: SendGrid: ${email}" |
|||
fn_script_log_fatal "Sending Email alert: SendGrid: ${email}" |
|||
else |
|||
fn_print_ok_nl "Sending Email alert: SendGrid: ${email}" |
|||
fn_script_log_pass "Sending Email alert: SendGrid: ${email}" |
|||
fi |
Loading…
Reference in new issue