Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
ruanhaishen
Acme.Sh
Commits
51099bf1
Unverified
Commit
51099bf1
authored
Jun 03, 2019
by
Honza Hommer
Browse files
Add postmark notify
parent
09bce5e6
Changes
1
Hide whitespace changes
Inline
Side-by-side
notify/postmark.sh
0 → 100644
View file @
51099bf1
#!/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
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment