3 #Support postmarkapp.com API (https://postmarkapp.com/developer/user-guide/sending-email/sending-with-api)
6 #POSTMARK_TO="xxxx@xxx.com"
7 #POSTMARK_FROM="xxxx@cccc.com"
12 _statusCode
="$3" #0: success, 1: error 2($RENEW_SKIP): skipped
13 _debug
"_statusCode" "$_statusCode"
15 POSTMARK_TOKEN
="${POSTMARK_TOKEN:-$(_readaccountconf_mutable POSTMARK_TOKEN)}"
16 if [ -z "$POSTMARK_TOKEN" ]; then
18 _err
"You didn't specify a POSTMARK api token POSTMARK_TOKEN yet ."
19 _err
"You can get yours from here https://account.postmarkapp.com"
22 _saveaccountconf_mutable POSTMARK_TOKEN
"$POSTMARK_TOKEN"
24 POSTMARK_TO
="${POSTMARK_TO:-$(_readaccountconf_mutable POSTMARK_TO)}"
25 if [ -z "$POSTMARK_TO" ]; then
27 _err
"You didn't specify an email to POSTMARK_TO receive messages."
30 _saveaccountconf_mutable POSTMARK_TO
"$POSTMARK_TO"
32 POSTMARK_FROM
="${POSTMARK_FROM:-$(_readaccountconf_mutable POSTMARK_FROM)}"
33 if [ -z "$POSTMARK_FROM" ]; then
35 _err
"You didn't specify an email from POSTMARK_FROM receive messages."
38 _saveaccountconf_mutable POSTMARK_FROM
"$POSTMARK_FROM"
40 export _H1
="Accept: application/json"
41 export _H2
="Content-Type: application/json"
42 export _H3
="X-Postmark-Server-Token: $POSTMARK_TOKEN"
44 _content
="$(echo "$_content" | _json_encode)"
45 _data
="{\"To\": \"$POSTMARK_TO\", \"From\": \"$POSTMARK_FROM\", \"Subject\": \"$_subject\", \"TextBody\": \"$_content\"}"
46 if _post
"$_data" "https://api.postmarkapp.com/email"; then
47 # shellcheck disable=SC2154
48 _message
=$
(printf "%s\n" "$response" | _lower_case | _egrep_o
"\"message\":\"[^\"]*\"" | cut
-d : -f 2 |
tr -d \" |
head -n 1)
49 if [ "$_message" = "ok" ]; then
50 _info
"postmark send success."
54 _err
"postmark send error."