filtrage sur les domaines
pas de dépollution pour les domaines présents dans /tmp/docker-mailserver/file_domaines_non_depollues.txt
This commit is contained in:
parent
eb5b3b3ec7
commit
c2656fd377
@ -72,18 +72,22 @@ MAX_FINAL_SIZE=2097152 # 2Mi
|
|||||||
ARCHIVE_TITLE="archive_content"
|
ARCHIVE_TITLE="archive_content"
|
||||||
ARCHIVE_MIME="text/kaz_email_archive"
|
ARCHIVE_MIME="text/kaz_email_archive"
|
||||||
|
|
||||||
|
FILE_SKIP_DOMAINS="/tmp/docker-mailserver/file_domaines_non_depollues.txt"
|
||||||
|
#on enlève les commentaires et les lignes vides
|
||||||
|
SKIP_DOMAINS=`grep -Ev '^#|^[[:space:]]*$' $FILE_SKIP_DOMAINS`
|
||||||
|
|
||||||
KEEP_FAILED=true
|
KEEP_FAILED=true
|
||||||
DEBUG=
|
DEBUG=true
|
||||||
|
|
||||||
#################### FONCTIONS ############################################
|
#################### FONCTIONS ############################################
|
||||||
BOLD='[1m'
|
BOLD='[1m'
|
||||||
RED='[0;31m'
|
RED='[0;31m'
|
||||||
GREEN='[0;32m'
|
GREEN='[0;32m'
|
||||||
YELLOW='[0;33m'
|
YELLOW='[0;33m'
|
||||||
BLUE='[0;34m'
|
BLUE='[0;34m'
|
||||||
MAGENTA='[0;35m'
|
MAGENTA='[0;35m'
|
||||||
CYAN='[0;36m'
|
CYAN='[0;36m'
|
||||||
NC='[0m' # No Color
|
NC='[0m' # No Color
|
||||||
NL='
|
NL='
|
||||||
'
|
'
|
||||||
|
|
||||||
@ -137,6 +141,26 @@ curlJirafeauSend () {
|
|||||||
echo "${OUTPUT}"
|
echo "${OUTPUT}"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Définir une fonction pour vérifier si le domaine d'un email est dans la liste SKIP_DOMAINS
|
||||||
|
function check_skip_domains() {
|
||||||
|
local SKIP_DOMAINS="$1"
|
||||||
|
local LIST_EMAILS="$2"
|
||||||
|
|
||||||
|
for email in $LIST_EMAILS; do
|
||||||
|
# Extraire le domaine de l'email (partie après le "@")
|
||||||
|
local domain="${email##*@}"
|
||||||
|
|
||||||
|
# Utiliser grep pour vérifier si le domaine est dans la liste des domaines à sauter
|
||||||
|
if echo "$SKIP_DOMAINS" | grep -q -w "$domain"; then
|
||||||
|
echo "yes"
|
||||||
|
return
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
# Si aucun domaine n'a été trouvé, retourner "no"
|
||||||
|
echo "no"
|
||||||
|
}
|
||||||
|
|
||||||
#################### MAIN #################################################
|
#################### MAIN #################################################
|
||||||
echo "${NL}${BLUE}$(date +%d-%m-%Y-%H-%M-%S)${NC} : ${GREEN}######################################## filter start (log in ${TMP_LOG})${NC}" >> "${FIC_LOG}"
|
echo "${NL}${BLUE}$(date +%d-%m-%Y-%H-%M-%S)${NC} : ${GREEN}######################################## filter start (log in ${TMP_LOG})${NC}" >> "${FIC_LOG}"
|
||||||
LOG_FIC "${GREEN}######################################## ${TMP_LOG} ${NC}"
|
LOG_FIC "${GREEN}######################################## ${TMP_LOG} ${NC}"
|
||||||
@ -145,6 +169,14 @@ if ! mkdir -p "${MAILS}"; then
|
|||||||
LOG_FIC "${RED}Can't mkdir ${MAILS} ${NC}"
|
LOG_FIC "${RED}Can't mkdir ${MAILS} ${NC}"
|
||||||
quitFilter "${EX_UNAVAILABLE}"
|
quitFilter "${EX_UNAVAILABLE}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
#$@ contient le sender et les destinataires
|
||||||
|
#format "-f sender -- dest1 [...dest(i)] "
|
||||||
|
LIST_EMAILS=$(echo $@)
|
||||||
|
#on nettoie
|
||||||
|
LIST_EMAILS=$(sed 's/-f//g' <<< $LIST_EMAILS)
|
||||||
|
LIST_EMAILS=$(sed 's/--//g' <<< $LIST_EMAILS)
|
||||||
|
|
||||||
MAIL_SOURCE=$(echo $@ | awk 'BEGIN{FS=" "} {print $2}')
|
MAIL_SOURCE=$(echo $@ | awk 'BEGIN{FS=" "} {print $2}')
|
||||||
DATE_TEMPS=$(date "+%Y-%m-%d-%H:%M:%S")
|
DATE_TEMPS=$(date "+%Y-%m-%d-%H:%M:%S")
|
||||||
REP_PIECE_JOINTE="${MAILS}/${DATE_TEMPS}_${MAIL_SOURCE}_$$"
|
REP_PIECE_JOINTE="${MAILS}/${DATE_TEMPS}_${MAIL_SOURCE}_$$"
|
||||||
@ -200,6 +232,13 @@ if [ "${MODE}" = "none" ]; then
|
|||||||
quitFilter 0
|
quitFilter 0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
||||||
|
if [ "$(check_skip_domains "$SKIP_DOMAINS" "$LIST_EMAILS")" = "yes" ]; then
|
||||||
|
LOG_FIC " - ${GREEN}send without change (skip domain)${NC}"
|
||||||
|
${SENDMAIL} "$@" < "${INSPECT_DIR}/in.$$"
|
||||||
|
quitFilter 0
|
||||||
|
fi
|
||||||
|
|
||||||
# Etape de rafraichissement des anciens fichiers inclus
|
# Etape de rafraichissement des anciens fichiers inclus
|
||||||
echo "time: ${DATE_TEMPS}${NL}id: $(date +%s)" > "${ARCHIVE_CONTENT}"
|
echo "time: ${DATE_TEMPS}${NL}id: $(date +%s)" > "${ARCHIVE_CONTENT}"
|
||||||
[ -n "${TRACK}" ] && echo "sender: ${MAIL_SOURCE}" >> "${ARCHIVE_CONTENT}"
|
[ -n "${TRACK}" ] && echo "sender: ${MAIL_SOURCE}" >> "${ARCHIVE_CONTENT}"
|
||||||
@ -322,3 +361,4 @@ fi
|
|||||||
quitFilter 0
|
quitFilter 0
|
||||||
|
|
||||||
##########################################################################
|
##########################################################################
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user