Unverified Commit 2e2e0561 authored by maxemann96's avatar maxemann96 Committed by GitHub
Browse files

Merge branch 'dev' into oath

parents e0d4115e a2738e85
#!/usr/bin/env sh
#Support postmarkapp.com API (https://postmarkapp.com/developer/user-guide/sending-email/sending-with-api)
#POSTMARK_TOKEN=""
#POSTMARK_TO="xxxx@xxx.com"
#POSTMARK_FROM="xxxx@cccc.com"
postmark_send() {
_subject="$1"
_content="$2"
_statusCode="$3" #0: success, 1: error 2($RENEW_SKIP): skipped
_debug "_statusCode" "$_statusCode"
POSTMARK_TOKEN="${POSTMARK_TOKEN:-$(_readaccountconf_mutable POSTMARK_TOKEN)}"
if [ -z "$POSTMARK_TOKEN" ]; then
POSTMARK_TOKEN=""
_err "You didn't specify a POSTMARK api token POSTMARK_TOKEN yet ."
_err "You can get yours from here https://account.postmarkapp.com"
return 1
fi
_saveaccountconf_mutable POSTMARK_TOKEN "$POSTMARK_TOKEN"
POSTMARK_TO="${POSTMARK_TO:-$(_readaccountconf_mutable POSTMARK_TO)}"
if [ -z "$POSTMARK_TO" ]; then
POSTMARK_TO=""
_err "You didn't specify an email to POSTMARK_TO receive messages."
return 1
fi
_saveaccountconf_mutable POSTMARK_TO "$POSTMARK_TO"
POSTMARK_FROM="${POSTMARK_FROM:-$(_readaccountconf_mutable POSTMARK_FROM)}"
if [ -z "$POSTMARK_FROM" ]; then
POSTMARK_FROM=""
_err "You didn't specify an email from POSTMARK_FROM receive messages."
return 1
fi
_saveaccountconf_mutable POSTMARK_FROM "$POSTMARK_FROM"
export _H1="Accept: application/json"
export _H2="Content-Type: application/json"
export _H3="X-Postmark-Server-Token: $POSTMARK_TOKEN"
_content="$(echo "$_content" | _json_encode)"
_data="{\"To\": \"$POSTMARK_TO\", \"From\": \"$POSTMARK_FROM\", \"Subject\": \"$_subject\", \"TextBody\": \"$_content\"}"
if _post "$_data" "https://api.postmarkapp.com/email"; then
# shellcheck disable=SC2154
_message=$(printf "%s\n" "$response" | _lower_case | _egrep_o "\"message\":\"[^\"]*\"" | cut -d : -f 2 | tr -d \" | head -n 1)
if [ "$_message" = "ok" ]; then
_info "postmark send success."
return 0
fi
fi
_err "postmark send error."
_err "$response"
return 1
}
#!/usr/bin/env sh
#Support SENDGRID.com api
#SENDGRID_API_KEY=""
#SENDGRID_TO="xxxx@xxx.com"
#SENDGRID_FROM="xxxx@cccc.com"
sendgrid_send() {
_subject="$1"
_content="$2"
_statusCode="$3" #0: success, 1: error 2($RENEW_SKIP): skipped
_debug "_statusCode" "$_statusCode"
SENDGRID_API_KEY="${SENDGRID_API_KEY:-$(_readaccountconf_mutable SENDGRID_API_KEY)}"
if [ -z "$SENDGRID_API_KEY" ]; then
SENDGRID_API_KEY=""
_err "You didn't specify a sendgrid api key SENDGRID_API_KEY yet ."
_err "You can get yours from here https://sendgrid.com"
return 1
fi
_saveaccountconf_mutable SENDGRID_API_KEY "$SENDGRID_API_KEY"
SENDGRID_TO="${SENDGRID_TO:-$(_readaccountconf_mutable SENDGRID_TO)}"
if [ -z "$SENDGRID_TO" ]; then
SENDGRID_TO=""
_err "You didn't specify an email to SENDGRID_TO receive messages."
return 1
fi
_saveaccountconf_mutable SENDGRID_TO "$SENDGRID_TO"
SENDGRID_FROM="${SENDGRID_FROM:-$(_readaccountconf_mutable SENDGRID_FROM)}"
if [ -z "$SENDGRID_FROM" ]; then
SENDGRID_FROM=""
_err "You didn't specify an email to SENDGRID_FROM receive messages."
return 1
fi
_saveaccountconf_mutable SENDGRID_FROM "$SENDGRID_FROM"
export _H1="Authorization: Bearer $SENDGRID_API_KEY"
export _H2="Content-Type: application/json"
_content="$(echo "$_content" | _json_encode)"
_data="{\"personalizations\": [{\"to\": [{\"email\": \"$SENDGRID_TO\"}]}],\"from\": {\"email\": \"$SENDGRID_FROM\"},\"subject\": \"$_subject\",\"content\": [{\"type\": \"text/plain\", \"value\": \"$_content\"}]}"
response="" #just make shellcheck happy
if _post "$_data" "https://api.sendgrid.com/v3/mail/send"; then
if [ -z "$response" ]; then
_info "sendgrid send sccess."
return 0
fi
fi
_err "sendgrid send error."
_err "$response"
return 1
}
#!/usr/bin/env sh
#Support Slack webhooks
#SLACK_WEBHOOK_URL=""
#SLACK_CHANNEL=""
#SLACK_USERNAME=""
slack_send() {
_subject="$1"
_content="$2"
_statusCode="$3" #0: success, 1: error 2($RENEW_SKIP): skipped
_debug "_statusCode" "$_statusCode"
SLACK_WEBHOOK_URL="${SLACK_WEBHOOK_URL:-$(_readaccountconf_mutable SLACK_WEBHOOK_URL)}"
if [ -z "$SLACK_WEBHOOK_URL" ]; then
SLACK_WEBHOOK_URL=""
_err "You didn't specify a Slack webhook url SLACK_WEBHOOK_URL yet."
return 1
fi
_saveaccountconf_mutable SLACK_WEBHOOK_URL "$SLACK_WEBHOOK_URL"
SLACK_CHANNEL="${SLACK_CHANNEL:-$(_readaccountconf_mutable SLACK_CHANNEL)}"
if [ -n "$SLACK_CHANNEL" ]; then
_saveaccountconf_mutable SLACK_CHANNEL "$SLACK_CHANNEL"
fi
SLACK_USERNAME="${SLACK_USERNAME:-$(_readaccountconf_mutable SLACK_USERNAME)}"
if [ -n "$SLACK_USERNAME" ]; then
_saveaccountconf_mutable SLACK_USERNAME "$SLACK_USERNAME"
fi
export _H1="Content-Type: application/json"
_content="$(printf "*%s*\n%s" "$_subject" "$_content" | _json_encode)"
_data="{\"text\": \"$_content\", "
if [ -n "$SLACK_CHANNEL" ]; then
_data="$_data\"channel\": \"$SLACK_CHANNEL\", "
fi
if [ -n "$SLACK_USERNAME" ]; then
_data="$_data\"username\": \"$SLACK_USERNAME\", "
fi
_data="$_data\"mrkdwn\": \"true\"}"
if _post "$_data" "$SLACK_WEBHOOK_URL"; then
# shellcheck disable=SC2154
if [ "$response" = "ok" ]; then
_info "slack send success."
return 0
fi
fi
_err "slack send error."
_err "$response"
return 1
}
#!/usr/bin/env sh
# support smtp
smtp_send() {
_subject="$1"
_content="$2"
_statusCode="$3" #0: success, 1: error 2($RENEW_SKIP): skipped
_debug "_subject" "$_subject"
_debug "_content" "$_content"
_debug "_statusCode" "$_statusCode"
_err "Not implemented yet."
return 1
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment