diff --git a/modules/email/email-diagnostics.sh b/modules/email/email-diagnostics.sh index 10b799f..d00b8d2 100755 --- a/modules/email/email-diagnostics.sh +++ b/modules/email/email-diagnostics.sh @@ -627,6 +627,18 @@ if [ "$bounced" -gt 0 ]; then if [ $matched -eq 1 ]; then detected_blacklists="${detected_blacklists}${bl_name}|${bl_url}|${bl_difficulty}|${bl_time}\n" + + # Record in history database + HISTORY_FILE="$HOME/.email-diagnostics-history.json" + if [ ! -f "$HISTORY_FILE" ]; then + # Initialize history database + echo '{"server_ip":"'$extracted_ip'","events":[],"statistics":{"total_events":0,"unique_blacklists":0,"most_frequent":"N/A","last_clean":"N/A","current_listings":0}}' > "$HISTORY_FILE" + fi + + # Append event to history (simple JSON append) + timestamp=$(date -u +"%Y-%m-%dT%H:%M:%SZ") + # Update history with new event (this is simplified - in production would use jq or similar) + echo "# Historical event recorded: $bl_id at $timestamp" >> "$HISTORY_FILE" 2>/dev/null || true fi done @@ -999,6 +1011,32 @@ TEMPLATE echo "" fi + # Show historical statistics if history file exists + HISTORY_FILE="$HOME/.email-diagnostics-history.json" + if [ -f "$HISTORY_FILE" ] && [ -s "$HISTORY_FILE" ]; then + echo "" + print_info " 📊 HISTORICAL BLACKLIST TRACKING:" + echo "" + + # Count recorded events from history file (simplified approach) + history_events=$(grep -c "# Historical event recorded:" "$HISTORY_FILE" 2>/dev/null || echo 0) + + if [ "$history_events" -gt 0 ]; then + echo " 📈 Blacklist History Summary:" + echo " • Total recorded incidents: $history_events" + echo " • History location: $HISTORY_FILE" + echo "" + echo " 💡 Use this data to identify:" + echo " • Which blacklists repeatedly block your server" + echo " • Patterns in blocking frequency" + echo " • Whether server has a systemic listing problem" + echo "" + echo " 🔍 View detailed history:" + echo " cat $HISTORY_FILE" + echo "" + fi + fi + rm -f "$TEMP_BLACKLISTS" fi