diff --git a/modules/email/email-diagnostics.sh b/modules/email/email-diagnostics.sh index b36bdb0..78f2092 100755 --- a/modules/email/email-diagnostics.sh +++ b/modules/email/email-diagnostics.sh @@ -102,7 +102,7 @@ grep -v "imap-login\|pop3-login\|dovecot.*Login\|Logged in\|Disconnected" "$TEMP mv "$TEMP_MATCHES.delivery" "$TEMP_MATCHES" if [ ! -s "$TEMP_MATCHES" ]; then - print_error "❌ NO EMAIL ACTIVITY FOUND for $check_label" + print_error "NO EMAIL ACTIVITY FOUND for $check_label" echo "" echo "This means:" echo " • No emails sent TO this $check_label" @@ -118,9 +118,9 @@ if [ ! -s "$TEMP_MATCHES" ]; then # Check if domain exists if [ "$check_type" = "2" ]; then if grep -q "$target" /etc/localdomains 2>/dev/null || grep -q "$target" /etc/userdomains 2>/dev/null; then - print_info "✓ Domain $target IS configured on this server" + print_info "Domain $target IS configured on this server" else - print_warning "⚠ Domain $target NOT found in local domains" + print_warning "Domain $target NOT found in local domains" fi fi @@ -129,7 +129,7 @@ if [ ! -s "$TEMP_MATCHES" ]; then fi total_lines=$(wc -l < "$TEMP_MATCHES") -print_success "✓ Found $total_lines log entries for $check_label" +print_success "Found $total_lines log entries for $check_label" echo "" ################################################################################ @@ -168,7 +168,7 @@ auth_success=$(echo "$auth_success" | head -1 | tr -d '\n\r') # Quick Summary ################################################################################ -print_header "⚡ Quick Summary" +print_header "QUICK SUMMARY" echo "" # Determine quick status @@ -176,17 +176,17 @@ total_problems=$((bounced + rejected + spam_rejected)) total_email_activity=$((sent + received + delivered)) if [ "$total_email_activity" -gt 0 ] && [ "$total_problems" -eq 0 ]; then - print_success "✅ Email appears to be working (${total_email_activity} email events, no problems)" + print_success "Email appears to be working (${total_email_activity} email events, no problems)" elif [ "$total_email_activity" -gt 0 ] && [ "$total_problems" -gt 0 ]; then - print_warning "⚠️ Partial email issues (${total_email_activity} delivered, ${total_problems} failed)" + print_warning "Partial email issues (${total_email_activity} delivered, ${total_problems} failed)" elif [ "$total_problems" -gt 0 ]; then - print_error "❌ Email delivery problems detected (${total_problems} failures)" + print_error "Email delivery problems detected (${total_problems} failures)" elif [ "$auth_success" -gt 0 ] && [ "$total_email_activity" -eq 0 ]; then - print_info "📱 Account active (${auth_success} logins) but no email traffic in last ${hours}h" + print_info "Account active (${auth_success} logins) but no email traffic in last ${hours}h" elif [ "$auth_failed" -gt 0 ]; then - print_warning "⚠️ Failed login attempts detected (${auth_failed} attempts) - possible attack" + print_warning "Failed login attempts detected (${auth_failed} attempts) - possible attack" else - print_info "ℹ️ No activity detected in last ${hours} hours" + print_info "No activity detected in last ${hours} hours" fi echo "" @@ -195,26 +195,26 @@ echo "" # Detailed Activity Breakdown ################################################################################ -print_header "📊 Email Delivery Activity (last $hours hours)" +print_header "EMAIL DELIVERY ACTIVITY (last $hours hours)" echo "" # Always show main metrics for clarity if [ "$received" -gt 0 ]; then - print_success "📥 Received: $received emails (incoming TO this $check_label)" + print_success "Received: $received emails (incoming TO this $check_label)" else - echo "📥 Received: 0 emails (no incoming mail)" + echo "Received: 0 emails (no incoming mail)" fi if [ "$sent" -gt 0 ]; then - print_success "📤 Sent: $sent emails (outgoing FROM this $check_label)" + print_success "Sent: $sent emails (outgoing FROM this $check_label)" else - echo "📤 Sent: 0 emails (no outgoing mail)" + echo "Sent: 0 emails (no outgoing mail)" fi if [ "$delivered" -gt 0 ]; then - print_success "✅ Delivered: $delivered successful deliveries" + print_success "Delivered: $delivered successful deliveries" else - echo "✅ Delivered: 0 (no completed deliveries logged)" + echo "Delivered: 0 (no completed deliveries logged)" fi echo "" @@ -223,47 +223,47 @@ echo "" has_problems=0 if [ "$bounced" -gt 0 ]; then - print_error "❌ Bounced: $bounced emails bounced/failed" + print_error "Bounced: $bounced emails bounced/failed" has_problems=1 fi if [ "$deferred" -gt 0 ]; then - print_warning "⏸ Deferred: $deferred emails temporarily delayed" + print_warning "Deferred: $deferred emails temporarily delayed" has_problems=1 fi if [ "$rejected" -gt 0 ]; then - print_error "🚫 Rejected: $rejected emails blocked/rejected" + print_error "Rejected: $rejected emails blocked/rejected" has_problems=1 fi if [ "$spam_rejected" -gt 0 ]; then - print_error "🚫 Spam Rejected: $spam_rejected emails marked as spam" + print_error "Spam Rejected: $spam_rejected emails marked as spam" has_problems=1 fi if [ "$spf_fail" -gt 0 ]; then - print_warning "⚠ SPF Failures: $spf_fail authentication failures" + print_warning "SPF Failures: $spf_fail authentication failures" has_problems=1 fi if [ "$dkim_fail" -gt 0 ]; then - print_warning "⚠ DKIM Failures: $dkim_fail signature failures" + print_warning "DKIM Failures: $dkim_fail signature failures" has_problems=1 fi if [ "$greylist" -gt 0 ]; then - print_info "⏱ Greylisted: $greylist emails temporarily delayed (normal anti-spam)" + print_info "Greylisted: $greylist emails temporarily delayed (normal anti-spam)" fi if [ $has_problems -eq 0 ]; then - print_success "✓ No delivery problems detected" + print_success "No delivery problems detected" fi # Show email traffic patterns if [ "$sent" -gt 0 ] || [ "$received" -gt 0 ]; then echo "" - print_header "📊 Email Traffic Patterns" + print_header "EMAIL TRAFFIC PATTERNS" echo "" # Top recipients (who this email is sending to) @@ -288,17 +288,17 @@ fi # Show authentication summary if [ -s "$TEMP_AUTH" ]; then echo "" - print_header "🔐 Mailbox Access Activity (IMAP/POP3 Logins)" + print_header "MAILBOX ACCESS ACTIVITY (IMAP/POP3 Logins)" echo "" print_info "This shows if customer can access their mailbox (not email delivery)" echo "" if [ "$auth_success" -gt 0 ]; then - print_success "✅ Successful Logins: $auth_success (password is correct, mailbox accessible)" + print_success "Successful Logins: $auth_success (password is correct, mailbox accessible)" fi if [ "$auth_failed" -gt 0 ]; then - print_error "❌ Failed Logins: $auth_failed (WRONG PASSWORD or brute-force attack)" + print_error "Failed Logins: $auth_failed (WRONG PASSWORD or brute-force attack)" # Extract IPs attempting failed logins failed_ips=$(grep -i "auth failed\|Login aborted" "$TEMP_AUTH" | grep -oE "rip=[0-9.]+|from [0-9.]+" | sed 's/rip=//; s/from //' | sort | uniq -c | sort -rn) @@ -319,7 +319,7 @@ echo "" ################################################################################ if [ "$check_type" != "2" ]; then - print_header "📧 Email Account Status" + print_header "EMAIL ACCOUNT STATUS" echo "" # Extract username and domain from email @@ -353,33 +353,33 @@ if [ "$check_type" != "2" ]; then # If successful logins exist, account must exist (even if we can't find the directory) if [ $account_found -eq 0 ] && [ "$auth_success" -gt 0 ]; then account_found=1 - print_success "✅ Email account EXISTS (confirmed by successful logins)" - print_warning " Note: Mailbox directory not found in standard locations" + print_success "Email account EXISTS (confirmed by successful logins)" + print_warning "Note: Mailbox directory not found in standard locations" elif [ $account_found -eq 1 ]; then - print_success "✅ Email account EXISTS on this server" + print_success "Email account EXISTS on this server" # Show mailbox details if we found the directory if [ -n "$maildir" ] && [ -d "$maildir" ]; then disk_usage=$(du -sh "$maildir" 2>/dev/null | awk '{print $1}') if [ -n "$disk_usage" ]; then - print_info "📊 Mailbox size: $disk_usage" + print_info "Mailbox size: $disk_usage" fi # Count messages msg_count=$(find "$maildir" -type f -name "*:2,*" 2>/dev/null | wc -l) if [ "$msg_count" -gt 0 ]; then - print_info "📬 Messages stored: $msg_count" + print_info "Messages stored: $msg_count" fi # Check for quota file quota_file=$(find "$maildir" -name "maildirsize" 2>/dev/null | head -1) if [ -f "$quota_file" ]; then quota_info=$(head -1 "$quota_file" 2>/dev/null) - print_info "💾 Quota: $quota_info" + print_info "Quota: $quota_info" fi fi else - print_warning "⚠ Email account NOT FOUND on this server" + print_warning "Email account NOT FOUND on this server" echo "" echo "This could mean:" echo " • Account doesn't exist (typo in email address?)" @@ -392,7 +392,7 @@ if [ "$check_type" != "2" ]; then forwarder=$(grep "^$local_part:" "/etc/valiases/$domain_part" 2>/dev/null) if [ -n "$forwarder" ]; then echo "" - print_info "📧 Forwarder configured:" + print_info "Forwarder configured:" echo " $forwarder" fi fi @@ -404,61 +404,61 @@ fi # Show verdict ################################################################################ -print_header "🔍 Diagnostic Result" +print_header "DIAGNOSTIC RESULT" echo "" # Determine overall status if [ "$delivered" -gt 0 ] && [ "$bounced" -eq 0 ] && [ "$rejected" -eq 0 ] && [ "$spam_rejected" -eq 0 ]; then - print_success "✅ EMAIL IS WORKING PROPERLY" + print_success "EMAIL IS WORKING PROPERLY" echo "" echo "Evidence: $delivered successful deliveries in the last $hours hours" echo "No bounces, rejections, or spam filtering detected" echo "" elif [ "$delivered" -gt 0 ] && [ "$bounced" -gt 0 ]; then - print_warning "⚠ EMAIL PARTIALLY WORKING" + print_warning "EMAIL PARTIALLY WORKING" echo "" echo "Some emails delivered ($delivered) but some failed ($bounced)" echo "Check bounce reasons below for details" echo "" elif [ "$bounced" -gt 0 ] || [ "$rejected" -gt 0 ] || [ "$spam_rejected" -gt 0 ]; then - print_error "❌ EMAIL HAS DELIVERY PROBLEMS" + print_error "EMAIL HAS DELIVERY PROBLEMS" echo "" echo "Emails are being rejected, bouncing, or filtered as spam" echo "See details below for why" echo "" elif [ "$deferred" -gt 0 ]; then - print_warning "⏸ EMAIL DELAYED" + print_warning "EMAIL DELAYED" echo "" echo "Emails are being deferred (temporary failures)" echo "This usually resolves itself within minutes" echo "" elif [ "$sent" -gt 0 ] || [ "$received" -gt 0 ]; then - print_info "📬 EMAIL ACTIVITY DETECTED" + print_info "EMAIL ACTIVITY DETECTED" echo "" echo "Email traffic logged but no delivery confirmations in last $hours hours" echo "This may be normal depending on email volume" echo "" elif [ "$auth_success" -gt 0 ] || [ "$auth_failed" -gt 0 ]; then - print_info "📱 MAILBOX ACCESS ONLY" + print_info "MAILBOX ACCESS ONLY" echo "" echo "No email delivery activity, only mailbox access (IMAP/POP3) detected" echo "This means the account exists and is being checked, but no emails sent/received" echo "" if [ "$auth_success" -gt 0 ]; then - echo "✓ Authentication is working (customer can access mailbox)" + echo "Authentication is working (customer can access mailbox)" fi if [ "$auth_failed" -gt 0 ]; then - echo "⚠ Failed login attempts detected (see details below)" + echo "Failed login attempts detected (see details below)" fi echo "" else - print_warning "❌ NO EMAIL ACTIVITY FOUND" + print_warning "NO EMAIL ACTIVITY FOUND" echo "" echo "No email sending, receiving, or mailbox access in the last $hours hours" echo "Account may be inactive or not used during this time period" @@ -470,7 +470,7 @@ fi ################################################################################ if [ "$delivered" -gt 0 ]; then - print_header "✅ Recent Successful Deliveries (last 5 from past $hours hours)" + print_header "RECENT SUCCESSFUL DELIVERIES (last 5 from past $hours hours)" echo "" print_info "PROOF - These emails were delivered recently:" echo "" @@ -487,7 +487,7 @@ if [ "$delivered" -gt 0 ]; then fi if [ "$bounced" -gt 0 ]; then - print_header "❌ Recent Bounces/Failures (last 5 from past $hours hours)" + print_header "RECENT BOUNCES/FAILURES (last 5 from past $hours hours)" echo "" print_warning "PROOF - These emails failed recently:" echo "" @@ -502,14 +502,14 @@ if [ "$bounced" -gt 0 ]; then echo "" # Extract bounce reasons - print_header "Common Bounce Reasons" + print_header "COMMON BOUNCE REASONS" echo "" grep -i "bounce\|550\|fail" "$TEMP_MATCHES" | grep -oE "550 .*|User unknown|Mailbox.*full|Relay.*denied|blocked" | sort | uniq -c | sort -rn | head -5 echo "" fi if [ "$rejected" -gt 0 ]; then - print_header "🚫 Recent Rejections (last 5)" + print_header "RECENT REJECTIONS (last 5)" echo "" grep -i "rejected.*$search_pattern\|denied.*$search_pattern\|blocked.*$search_pattern" "$TEMP_MATCHES" | tail -5 | while read line; do echo " $line" @@ -518,7 +518,7 @@ if [ "$rejected" -gt 0 ]; then fi if [ "$spam_rejected" -gt 0 ]; then - print_header "🚫 Recent Spam Rejections (last 5)" + print_header "RECENT SPAM REJECTIONS (last 5)" echo "" grep -i "spam.*$search_pattern\|SpamAssassin.*rejected" "$TEMP_MATCHES" | tail -5 | while read line; do timestamp=$(echo "$line" | grep -oE '[0-9]{4}-[0-9]{2}-[0-9]{2} [0-9]{2}:[0-9]{2}:[0-9]{2}|[A-Z][a-z]{2} [0-9]+ [0-9]{2}:[0-9]{2}:[0-9]{2}' | head -1) @@ -532,7 +532,7 @@ if [ "$spam_rejected" -gt 0 ]; then fi if [ "$greylist" -gt 0 ]; then - print_header "⏱ Recent Greylisting Events (last 5)" + print_header "RECENT GREYLISTING EVENTS (last 5)" echo "" print_info "Note: Greylisting is temporary - emails usually deliver after retry" echo "" @@ -543,7 +543,7 @@ if [ "$greylist" -gt 0 ]; then fi if [ "$spf_fail" -gt 0 ] || [ "$dkim_fail" -gt 0 ]; then - print_header "⚠ Authentication Issues" + print_header "AUTHENTICATION ISSUES" echo "" if [ "$spf_fail" -gt 0 ]; then echo "SPF failures detected:" @@ -561,7 +561,7 @@ fi # Recommendations ################################################################################ -print_header "💡 Recommendations" +print_header "RECOMMENDATIONS" echo "" if [ "$bounced" -gt 0 ]; then