File tree Expand file tree Collapse file tree 1 file changed +10
-3
lines changed Expand file tree Collapse file tree 1 file changed +10
-3
lines changed Original file line number Diff line number Diff line change @@ -15,6 +15,7 @@ KINESIS_REGION="${KINESIS_REGION:-}"
15
15
WEBHOOK_URL=" ${WEBHOOK_URL:- } "
16
16
FORWARD_EMAIL=" ${FORWARD_EMAIL:- } "
17
17
DOMAIN_FILTER=" ${DOMAIN_FILTER:- msg.domaineasy.com} "
18
+ REMOVE_TEMP_EMAIL=" ${REMOVE_TEMP_EMAIL:- true} "
18
19
19
20
# Log the incoming email for debugging purposes
20
21
echo " Email received at $( date) "
@@ -36,15 +37,21 @@ echo "Received an email from: $from to $to with subject: $subject"
36
37
# Check if the 'To' field matches the specified domain
37
38
if [ -n " $DOMAIN_FILTER " ] && ! grep -iq " ^To:.*@$DOMAIN_FILTER " " $TEMP_EMAIL_FILE " ; then
38
39
echo " Email does not match the 'To' domain '$DOMAIN_FILTER '. Ignoring."
39
- rm -f " $TEMP_EMAIL_FILE "
40
+
41
+ # Conditionally remove the temp email file based on the REMOVE_TEMP_EMAIL variable
42
+ if [ " $REMOVE_TEMP_EMAIL " = " true" ]; then
43
+ rm -f " $TEMP_EMAIL_FILE "
44
+ fi
40
45
exit 0
41
46
fi
42
47
43
48
# Read the entire email content
44
49
email_content=$( cat " $TEMP_EMAIL_FILE " )
45
50
46
- # Cleanup: remove the temporary email file as soon as possible
47
- rm -f " $TEMP_EMAIL_FILE "
51
+ # Cleanup: Conditionally remove the temporary email file
52
+ if [ " $REMOVE_TEMP_EMAIL " = " true" ]; then
53
+ rm -f " $TEMP_EMAIL_FILE "
54
+ fi
48
55
49
56
# Function to send email to Kinesis
50
57
send_to_kinesis () {
You can’t perform that action at this time.
0 commit comments