feat: disable e-mail validation if MAIL_NOVALIDATE is set

This commit is contained in:
Honza Hommer 2019-05-26 06:53:24 +02:00
parent 2aa219e150
commit 2adeed885e
No known key found for this signature in database
GPG Key ID: 5EBDE8E7E1A00ACA

View File

@ -5,6 +5,7 @@
#MAIL_BIN="sendmail" #MAIL_BIN="sendmail"
#MAIL_FROM="yyyy@gmail.com" #MAIL_FROM="yyyy@gmail.com"
#MAIL_TO="yyyy@gmail.com" #MAIL_TO="yyyy@gmail.com"
#MAIL_NOVALIDATE=""
mail_send() { mail_send() {
_subject="$1" _subject="$1"
@ -14,6 +15,13 @@ mail_send() {
_debug "_content" "$_content" _debug "_content" "$_content"
_debug "_statusCode" "$_statusCode" _debug "_statusCode" "$_statusCode"
MAIL_NOVALIDATE="${MAIL_NOVALIDATE:-$(_readaccountconf_mutable MAIL_NOVALIDATE)}"
if [ -n "$MAIL_NOVALIDATE" ]; then
_saveaccountconf_mutable MAIL_NOVALIDATE 1
else
_clearaccountconf "MAIL_NOVALIDATE"
fi
MAIL_BIN="${MAIL_BIN:-$(_readaccountconf_mutable MAIL_BIN)}" MAIL_BIN="${MAIL_BIN:-$(_readaccountconf_mutable MAIL_BIN)}"
if [ -n "$MAIL_BIN" ] && ! _exists "$MAIL_BIN"; then if [ -n "$MAIL_BIN" ] && ! _exists "$MAIL_BIN"; then
_err "It seems that the command $MAIL_BIN is not in path." _err "It seems that the command $MAIL_BIN is not in path."
@ -29,7 +37,7 @@ mail_send() {
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
if ! _contains "$MAIL_FROM" "@"; then if ! _mail_valid "$MAIL_FROM"; then
_err "It seems that the MAIL_FROM=$MAIL_FROM is not a valid email address." _err "It seems that the MAIL_FROM=$MAIL_FROM is not a valid email address."
return 1 return 1
fi fi
@ -39,7 +47,7 @@ mail_send() {
MAIL_TO="${MAIL_TO:-$(_readaccountconf_mutable MAIL_TO)}" MAIL_TO="${MAIL_TO:-$(_readaccountconf_mutable MAIL_TO)}"
if [ -n "$MAIL_TO" ]; then if [ -n "$MAIL_TO" ]; then
if ! _contains "$MAIL_TO" "@"; then if ! _mail_valid "$MAIL_TO"; then
_err "It seems that the MAIL_TO=$MAIL_TO is not a valid email address." _err "It seems that the MAIL_TO=$MAIL_TO is not a valid email address."
return 1 return 1
fi fi
@ -118,3 +126,7 @@ _mail_body() {
echo "$_content" echo "$_content"
} }
_mail_valid() {
[ -n "$MAIL_NOVALIDATE" ] || _contains "$1" "@"
}