fix format

This commit is contained in:
neilpang 2019-04-29 21:07:04 +08:00
parent ea881189f7
commit 45a8bdbedc
2 changed files with 5 additions and 3 deletions

View File

@ -16,6 +16,7 @@ mailgun_send() {
_subject="$1" _subject="$1"
_content="$2" _content="$2"
_statusCode="$3" #0: success, 1: error 2($RENEW_SKIP): skipped _statusCode="$3" #0: success, 1: error 2($RENEW_SKIP): skipped
_debug "_statusCode" "$_statusCode"
MAILGUN_API_KEY="${MAILGUN_API_KEY:-$(_readaccountconf_mutable MAILGUN_API_KEY)}" MAILGUN_API_KEY="${MAILGUN_API_KEY:-$(_readaccountconf_mutable MAILGUN_API_KEY)}"
if [ -z "$MAILGUN_API_KEY" ]; then if [ -z "$MAILGUN_API_KEY" ]; then
@ -112,7 +113,7 @@ _mailgun_rest() {
response="$(_post "$_mgdata" "$_mgurl" "" "$_method")" response="$(_post "$_mgdata" "$_mgurl" "" "$_method")"
fi fi
if [ "$?" != "0" ]; then if [ "$?" != "0" ]; then
_err "Error: $ep" _err "Error: $_mguri"
_err "$response" _err "$response"
return 1 return 1
fi fi

View File

@ -10,6 +10,7 @@ sendgrid_send() {
_subject="$1" _subject="$1"
_content="$2" _content="$2"
_statusCode="$3" #0: success, 1: error 2($RENEW_SKIP): skipped _statusCode="$3" #0: success, 1: error 2($RENEW_SKIP): skipped
_debug "_statusCode" "$_statusCode"
SENDGRID_API_KEY="${SENDGRID_API_KEY:-$(_readaccountconf_mutable SENDGRID_API_KEY)}" SENDGRID_API_KEY="${SENDGRID_API_KEY:-$(_readaccountconf_mutable SENDGRID_API_KEY)}"
if [ -z "$SENDGRID_API_KEY" ]; then if [ -z "$SENDGRID_API_KEY" ]; then
@ -41,7 +42,7 @@ sendgrid_send() {
_content="$(echo "$_content" | _json_encode)" _content="$(echo "$_content" | _json_encode)"
_data="{\"personalizations\": [{\"to\": [{\"email\": \"$SENDGRID_TO\"}]}],\"from\": {\"email\": \"$SENDGRID_FROM\"},\"subject\": \"$_subject\",\"content\": [{\"type\": \"text/plain\", \"value\": \"$_content\"}]}" _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 _post "$_data" "https://api.sendgrid.com/v3/mail/send"; then
if [ -z "$response" ]; then if [ -z "$response" ]; then
_info "sendgrid send sccess." _info "sendgrid send sccess."
@ -50,6 +51,6 @@ sendgrid_send() {
fi fi
_err "sendgrid send error." _err "sendgrid send error."
_err "$response" _err "$response"
return 1; return 1
} }