Skip to content

Commit add9fc3

Browse files
committed
Do not attempt to reply to spam emails from Fortune script
1 parent ee32f14 commit add9fc3

1 file changed

Lines changed: 8 additions & 0 deletions

File tree

‎ansible/roles/postfix/templates/services/fortune-reply.sh.j2‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,14 @@ MESSAGE_ID=$(echo "$EMAIL" | mhdr -h message-id -)
1212
# Extract the original Subject and prefix it with "Re: " if necessary
1313
ORIGINAL_SUBJECT=$(echo "$EMAIL" | mhdr -h subject -)
1414

15+
# If marked as spam by SpamAssassin, do not reply
16+
SPAM_STATUS=$(echo "$EMAIL" | mhdr -h "X-Spam-Status" -)
17+
18+
if [[ "$SPAM_STATUS" =~ ^Yes ]]; then
19+
echo "Email marked as spam. Aborting."
20+
exit 0
21+
fi
22+
1523
# Construct the reply subject
1624
REPLY_SUBJECT="Re: $ORIGINAL_SUBJECT"
1725

0 commit comments

Comments
 (0)