Compare commits
6 Commits
Author | SHA1 | Date | |
---|---|---|---|
|
94659482cf | ||
|
3ac1bec5d9 | ||
|
4c61cf5c81 | ||
|
aea24bbe89 | ||
bd3a2bc0c8 | |||
b0e3c5b390 |
@ -72,18 +72,22 @@ MAX_FINAL_SIZE=2097152 # 2Mi
|
||||
ARCHIVE_TITLE="archive_content"
|
||||
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
|
||||
DEBUG=
|
||||
DEBUG=true
|
||||
|
||||
#################### FONCTIONS ############################################
|
||||
BOLD='[1m'
|
||||
RED='[0;31m'
|
||||
GREEN='[0;32m'
|
||||
YELLOW='[0;33m'
|
||||
BLUE='[0;34m'
|
||||
MAGENTA='[0;35m'
|
||||
CYAN='[0;36m'
|
||||
NC='[0m' # No Color
|
||||
BOLD='[1m'
|
||||
RED='[0;31m'
|
||||
GREEN='[0;32m'
|
||||
YELLOW='[0;33m'
|
||||
BLUE='[0;34m'
|
||||
MAGENTA='[0;35m'
|
||||
CYAN='[0;36m'
|
||||
NC='[0m' # No Color
|
||||
NL='
|
||||
'
|
||||
|
||||
@ -137,6 +141,26 @@ curlJirafeauSend () {
|
||||
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 #################################################
|
||||
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}"
|
||||
@ -145,6 +169,14 @@ if ! mkdir -p "${MAILS}"; then
|
||||
LOG_FIC "${RED}Can't mkdir ${MAILS} ${NC}"
|
||||
quitFilter "${EX_UNAVAILABLE}"
|
||||
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}')
|
||||
DATE_TEMPS=$(date "+%Y-%m-%d-%H:%M:%S")
|
||||
REP_PIECE_JOINTE="${MAILS}/${DATE_TEMPS}_${MAIL_SOURCE}_$$"
|
||||
@ -200,6 +232,13 @@ if [ "${MODE}" = "none" ]; then
|
||||
quitFilter 0
|
||||
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
|
||||
echo "time: ${DATE_TEMPS}${NL}id: $(date +%s)" > "${ARCHIVE_CONTENT}"
|
||||
[ -n "${TRACK}" ] && echo "sender: ${MAIL_SOURCE}" >> "${ARCHIVE_CONTENT}"
|
||||
@ -322,3 +361,4 @@ fi
|
||||
quitFilter 0
|
||||
|
||||
##########################################################################
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user