#!/bin/bash get_tool_name() { echo "IMAP and POP3 Accessibility Checker" } get_tool_description() { echo "Check IMAP and POP3 accessibility for a domain" } execute_tool() { result="" if [ -n "$domain" ]; then if [[ "$domain" == *$'\n'* ]]; then for single_domain in $domain; do process_domain "$single_domain" done else process_domain "$domain" fi else result="No domains specified." fi echo -e "$result" } process_domain() { local single_domain="$1" result+="\e[1mDomain:\e[93m $single_domain\e[0m\n" mx_record=$(dig +short MX "$single_domain" | sort -n | head -n 1 | awk '{print $2}') if [ -z "$mx_record" ]; then mx_record="$single_domain" fi if command -v telnet &> /dev/null; then imap143_status=$(timeout 10 telnet "$mx_record" 143 <<< "quit" > /dev/null 2>&1 && echo "Connected" || echo "Failed") imap993_status=$(timeout 10 telnet "$mx_record" 993 <<< "quit" > /dev/null 2>&1 && echo "Connected" || echo "Failed") pop3110_status=$(timeout 10 telnet "$mx_record" 110 <<< "quit" > /dev/null 2>&1 && echo "Connected" || echo "Failed") pop3995_status=$(timeout 10 telnet "$mx_record" 995 <<< "quit" > /dev/null 2>&1 && echo "Connected" || echo "Failed") elif command -v nc &> /dev/null; then imap143_status=$(timeout 10 nc -z "$mx_record" 143 > /dev/null 2>&1 && echo "Connected" || echo "Failed") imap993_status=$(timeout 10 nc -z "$mx_record" 993 > /dev/null 2>&1 && echo "Connected" || echo "Failed") pop3110_status=$(timeout 10 nc -z "$mx_record" 110 > /dev/null 2>&1 && echo "Connected" || echo "Failed") pop3995_status=$(timeout 10 nc -z "$mx_record" 995 > /dev/null 2>&1 && echo "Connected" || echo "Failed") else result+="\e[1mDomain:\e[93m $single_domain\e[0m\n" result+="\e[1mIMAP Accessibility:\e[0m Netcat and Telnet not available.\n" result+="\e[1mPOP3 Accessibility:\e[0m Netcat and Telnet not available.\n" return fi result+="\e[1mDomain:\e[0m $single_domain\n" result+="\e[1mIMAP Accessibility (Port 143):\e[0m $imap143_status\n" result+="\e[1mIMAP Accessibility (Port 993):\e[0m $imap993_status\n" result+="\e[1mPOP3 Accessibility (Port 110):\e[0m $pop3110_status\n" result+="\e[1mPOP3 Accessibility (Port 995):\e[0m $pop3995_status\n" }