From dcf2ccd41427318c1553de1d8d109aaf54fb8851 Mon Sep 17 00:00:00 2001 From: cschantz Date: Wed, 31 Dec 2025 19:24:00 -0500 Subject: [PATCH] Fix integer expression errors in failure categorization Sanitize all grep counts to remove newlines that cause 'integer expression required' errors --- modules/email/email-diagnostics.sh | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/modules/email/email-diagnostics.sh b/modules/email/email-diagnostics.sh index b43ea03..f31d605 100755 --- a/modules/email/email-diagnostics.sh +++ b/modules/email/email-diagnostics.sh @@ -514,13 +514,19 @@ if [ "$bounced" -gt 0 ]; then TEMP_BOUNCES="/tmp/email_bounces_$$.txt" grep -i "$search_pattern" "$TEMP_MATCHES" | grep -v "authenticator failed\|Authentication failed\|saved mail to\|=>" | grep -i "550\|551\|552\|553\|554\|bounced\|Mail delivery failed\|** " > "$TEMP_BOUNCES" 2>/dev/null - # Categorize failures + # Categorize failures (sanitize counts to remove newlines) recipient_unknown=$(grep -ci "user unknown\|No such user\|does not exist\|recipient rejected\|Recipient address rejected\|550.*User" "$TEMP_BOUNCES" 2>/dev/null || echo 0) + recipient_unknown=$(echo "$recipient_unknown" | head -1 | tr -d '\n\r') mailbox_full=$(grep -ci "mailbox.*full\|quota.*exceeded\|552\|insufficient.*space\|over.*quota" "$TEMP_BOUNCES" 2>/dev/null || echo 0) + mailbox_full=$(echo "$mailbox_full" | head -1 | tr -d '\n\r') relay_denied=$(grep -ci "relay.*denied\|relay.*not.*permitted\|relaying denied\|554.*relay" "$TEMP_BOUNCES" 2>/dev/null || echo 0) + relay_denied=$(echo "$relay_denied" | head -1 | tr -d '\n\r') blocked=$(grep -ci "blocked\|blacklist\|550.*spam\|554.*spam\|Policy rejection" "$TEMP_BOUNCES" 2>/dev/null || echo 0) + blocked=$(echo "$blocked" | head -1 | tr -d '\n\r') dns_failure=$(grep -ci "domain.*not.*found\|Host.*unknown\|Name.*not.*resolve\|MX.*not.*found" "$TEMP_BOUNCES" 2>/dev/null || echo 0) + dns_failure=$(echo "$dns_failure" | head -1 | tr -d '\n\r') connection_fail=$(grep -ci "timeout\|connection.*refused\|connection.*failed\|Network.*unreachable" "$TEMP_BOUNCES" 2>/dev/null || echo 0) + connection_fail=$(echo "$connection_fail" | head -1 | tr -d '\n\r') print_info "Failure breakdown by reason:" echo ""