mirror of
https://github.com/plantroon/acme.sh.git
synced 2024-12-22 13:11:41 +00:00
expose MAIL_BIN variable
This commit is contained in:
parent
7b6ebc5c98
commit
e3052c8c57
@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
#Support local mail app
|
#Support local mail app
|
||||||
|
|
||||||
|
#MAIL_BIN="sendmail"
|
||||||
#MAIL_FROM="yyyy@gmail.com"
|
#MAIL_FROM="yyyy@gmail.com"
|
||||||
#MAIL_TO="yyyy@gmail.com"
|
#MAIL_TO="yyyy@gmail.com"
|
||||||
|
|
||||||
@ -13,18 +14,18 @@ mail_send() {
|
|||||||
_debug "_content" "$_content"
|
_debug "_content" "$_content"
|
||||||
_debug "_statusCode" "$_statusCode"
|
_debug "_statusCode" "$_statusCode"
|
||||||
|
|
||||||
if _exists "sendmail"; then
|
unset -f _MAIL_BIN _MAIL_BODY _MAIL_CMD
|
||||||
_MAIL_BIN="sendmail"
|
|
||||||
elif _exists "ssmtp"; then
|
MAIL_BIN="${MAIL_BIN:-$(_readaccountconf_mutable MAIL_BIN)}"
|
||||||
_MAIL_BIN="ssmtp"
|
if [ -n "$MAIL_BIN" ] && ! _exists "$MAIL_BIN"; then
|
||||||
elif _exists "mutt"; then
|
_err "It seems that the command $MAIL_BIN is not in path."
|
||||||
_MAIL_BIN="mutt"
|
|
||||||
elif _exists "mail"; then
|
|
||||||
_MAIL_BIN="mail"
|
|
||||||
else
|
|
||||||
_err "Please install sendmail, ssmtp, mutt or mail first."
|
|
||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
|
_MAIL_CMD=$(_mail_cmnd)
|
||||||
|
if [ -n "$MAIL_BIN" ]; then
|
||||||
|
_saveaccountconf_mutable MAIL_BIN "$MAIL_BIN"
|
||||||
|
fi
|
||||||
|
_MAIL_BODY=$(_mail_body)
|
||||||
|
|
||||||
MAIL_FROM="${MAIL_FROM:-$(_readaccountconf_mutable MAIL_FROM)}"
|
MAIL_FROM="${MAIL_FROM:-$(_readaccountconf_mutable MAIL_FROM)}"
|
||||||
if [ -n "$MAIL_FROM" ]; then
|
if [ -n "$MAIL_FROM" ]; then
|
||||||
@ -47,6 +48,8 @@ mail_send() {
|
|||||||
else
|
else
|
||||||
MAIL_TO="$(_readaccountconf ACCOUNT_EMAIL)"
|
MAIL_TO="$(_readaccountconf ACCOUNT_EMAIL)"
|
||||||
|
|
||||||
|
echo "MAIL_TO: $MAIL_TO"
|
||||||
|
|
||||||
if [ -z "$MAIL_TO" ]; then
|
if [ -z "$MAIL_TO" ]; then
|
||||||
_err "It seems that account email is empty."
|
_err "It seems that account email is empty."
|
||||||
return 1
|
return 1
|
||||||
@ -55,7 +58,7 @@ mail_send() {
|
|||||||
|
|
||||||
contenttype="text/plain; charset=utf-8"
|
contenttype="text/plain; charset=utf-8"
|
||||||
subject="=?UTF-8?B?$(echo "$_subject" | _base64)?="
|
subject="=?UTF-8?B?$(echo "$_subject" | _base64)?="
|
||||||
result=$({ _mail_body | _mail_send; } 2>&1)
|
result=$({ echo "$_MAIL_BODY" | eval "$_MAIL_CMD"; } 2>&1)
|
||||||
|
|
||||||
if [ $? -ne 0 ]; then
|
if [ $? -ne 0 ]; then
|
||||||
_debug "mail send error."
|
_debug "mail send error."
|
||||||
@ -67,20 +70,39 @@ mail_send() {
|
|||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
_mail_send() {
|
_mail_cmnd() {
|
||||||
|
if [ -n "$MAIL_BIN" ]; then
|
||||||
|
_MAIL_BIN=$(basename "$MAIL_BIN")
|
||||||
|
elif _exists "sendmail"; then
|
||||||
|
_MAIL_BIN="sendmail"
|
||||||
|
elif _exists "ssmtp"; then
|
||||||
|
_MAIL_BIN="ssmtp"
|
||||||
|
elif _exists "mutt"; then
|
||||||
|
_MAIL_BIN="mutt"
|
||||||
|
elif _exists "mail"; then
|
||||||
|
_MAIL_BIN="mail"
|
||||||
|
else
|
||||||
|
_err "Please install sendmail, ssmtp, mutt or mail first."
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
|
||||||
case "$_MAIL_BIN" in
|
case "$_MAIL_BIN" in
|
||||||
sendmail)
|
sendmail)
|
||||||
if [ -n "$MAIL_FROM" ]; then
|
if [ -n "$MAIL_FROM" ]; then
|
||||||
"$_MAIL_BIN" -f "$MAIL_FROM" "$MAIL_TO"
|
echo "'$_MAIL_BIN' -f '$MAIL_FROM' '$MAIL_TO'"
|
||||||
else
|
else
|
||||||
"$_MAIL_BIN" "$MAIL_TO"
|
echo "'$_MAIL_BIN' '$MAIL_TO'"
|
||||||
fi
|
fi
|
||||||
;;
|
;;
|
||||||
ssmtp)
|
ssmtp)
|
||||||
"$_MAIL_BIN" "$MAIL_TO"
|
echo "'$_MAIL_BIN' '$MAIL_TO'"
|
||||||
;;
|
;;
|
||||||
mutt | mail)
|
mutt | mail)
|
||||||
"$_MAIL_BIN" -s "$_subject" "$MAIL_TO"
|
echo "'$_MAIL_BIN' -s '$_subject' '$MAIL_TO'"
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
_err "Command $MAIL_BIN is not supported, use sendmail, ssmtp, mutt or mail."
|
||||||
|
return 1
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user