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
f6f6d89e
Unverified
Commit
f6f6d89e
authored
May 12, 2019
by
Honza Hommer
Browse files
move sendmail notify to mail notify
parent
4f035486
Changes
2
Hide whitespace changes
Inline
Side-by-side
notify/mail.sh
View file @
f6f6d89e
#!/usr/bin/env sh
# support local mail app
#Support local mail app
#MAIL_FROM="yyyy@gmail.com"
#MAIL_TO="yyyy@gmail.com"
mail_send
()
{
_subject
=
"
$1
"
...
...
@@ -10,6 +13,61 @@ mail_send() {
_debug
"_content"
"
$_content
"
_debug
"_statusCode"
"
$_statusCode
"
_err
"Not implemented yet."
return
1
if
_exists
"sendmail"
;
then
_MAIL_BIN
=
"sendmail"
elif
_exists
"mail"
;
then
_MAIL_BIN
=
"mail"
else
_err
"Please install mail or sendmail first."
return
1
fi
MAIL_FROM
=
"
${
MAIL_FROM
:-
$(
_readaccountconf_mutable MAIL_FROM
)
}
"
if
[
-z
"
$MAIL_FROM
"
]
;
then
MAIL_FROM
=
"
$USER
@
$(
hostname
-f
)
"
_info
"The MAIL_FROM is not set, so use the default value:
$MAIL_FROM
"
fi
_saveaccountconf_mutable MAIL_FROM
"
$MAIL_FROM
"
MAIL_TO
=
"
${
MAIL_TO
:-
$(
_readaccountconf_mutable MAIL_TO
)
}
"
if
[
-z
"
$MAIL_TO
"
]
;
then
MAIL_TO
=
"
$(
_readaccountconf ACCOUNT_EMAIL
)
"
_info
"The MAIL_TO is not set, so use the account email:
$MAIL_TO
"
fi
_saveaccountconf_mutable MAIL_TO
"
$MAIL_TO
"
subject
=
"=?UTF-8?B?
$(
echo
"
$_subject
"
| _base64
)
?="
result
=
$(
{
_mail_body | _mail_send
;
}
2>&1
)
if
[
$?
-ne
0
]
;
then
_debug
"mail send error."
_err
"
$result
"
return
1
fi
_debug
"mail send success."
return
0
}
_mail_send
()
{
case
"
$_MAIL_BIN
"
in
sendmail
)
sendmail
-f
"
$MAIL_FROM
"
"
$MAIL_TO
"
;;
mail
)
mail
-s
"
$subject
"
-a
"From:
$MAIL_FROM
"
-a
"Content-Type:text/plain; charset=utf-8"
"
$MAIL_TO
"
;;
esac
}
_mail_body
()
{
if
[
"
$_MAIL_BIN
"
=
"sendmail"
]
;
then
echo
"From:
$MAIL_FROM
"
echo
"To:
$MAIL_TO
"
echo
"Subject: =?UTF-8?B?
$(
echo
"
$_subject
"
| _base64
)
?="
echo
"Content-Type: text/plain; charset=utf-8"
echo
fi
echo
"
$_content
"
}
notify/sendmail.sh
deleted
100644 → 0
View file @
4f035486
#!/usr/bin/env sh
#Support sendmail
#SENDMAIL_BIN="sendmail"
#SENDMAIL_FROM="yyyy@gmail.com"
#SENDMAIL_TO="yyyy@gmail.com"
sendmail_send
()
{
_subject
=
"
$1
"
_content
=
"
$2
"
_statusCode
=
"
$3
"
#0: success, 1: error 2($RENEW_SKIP): skipped
_debug
"_subject"
"
$_subject
"
_debug
"_content"
"
$_content
"
_debug
"_statusCode"
"
$_statusCode
"
SENDMAIL_BIN
=
"
${
SENDMAIL_BIN
:-
$(
_readaccountconf_mutable SENDMAIL_BIN
)
}
"
if
[
-z
"
$SENDMAIL_BIN
"
]
;
then
SENDMAIL_BIN
=
"sendmail"
_info
"The SENDMAIL_BIN is not set, so use the default value:
$SENDMAIL_BIN
"
fi
if
!
_exists
"
$SENDMAIL_BIN
"
;
then
_err
"Please install sendmail first."
return
1
fi
_saveaccountconf_mutable SENDMAIL_BIN
"
$SENDMAIL_BIN
"
SENDMAIL_FROM
=
"
${
SENDMAIL_FROM
:-
$(
_readaccountconf_mutable SENDMAIL_FROM
)
}
"
if
[
-z
"
$SENDMAIL_FROM
"
]
;
then
SENDMAIL_FROM
=
"
$USER
@
$(
hostname
-f
)
"
_info
"The SENDMAIL_FROM is not set, so use the default value:
$SENDMAIL_FROM
"
fi
_saveaccountconf_mutable SENDMAIL_FROM
"
$SENDMAIL_FROM
"
SENDMAIL_TO
=
"
${
SENDMAIL_TO
:-
$(
_readaccountconf_mutable SENDMAIL_TO
)
}
"
if
[
-z
"
$SENDMAIL_TO
"
]
;
then
SENDMAIL_TO
=
"
$(
_readaccountconf ACCOUNT_EMAIL
)
"
_info
"The SENDMAIL_TO is not set, so use the account email:
$SENDMAIL_TO
"
fi
_saveaccountconf_mutable SENDMAIL_TO
"
$SENDMAIL_TO
"
subject
=
"=?UTF-8?B?
$(
echo
"
$_subject
"
| _base64
)
?="
error
=
$(
{
echo
"From:
$SENDMAIL_FROM
To:
$SENDMAIL_TO
Subject:
$subject
Content-Type: text/plain; charset=utf-8
$_content
"
|
"
$SENDMAIL_BIN
"
-f
"
$SENDMAIL_FROM
"
"
$SENDMAIL_TO
"
;
}
2>&1
)
if
[
$?
-ne
0
]
;
then
_debug
"sendmail send error."
_err
"
$error
"
return
1
fi
_debug
"sendmail send success."
return
0
}
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