mirror of
https://github.com/hyzendust/mutt-add-account.git
synced 2026-02-15 02:21:12 +01:00
Add: detect server settings from file
This commit is contained in:
@@ -302,6 +302,48 @@ read -p "Enter account name: " shortname
|
||||
email_domain="${email#*@}"
|
||||
echo "Searching for server settings..."
|
||||
|
||||
# Download/update domains.csv
|
||||
domains_csv="$HOME/.mutt/domains.csv"
|
||||
echo "Fetching known mail server configurations..."
|
||||
curl -fsSL "https://raw.githubusercontent.com/LukeSmithxyz/mutt-wizard/refs/heads/master/share/domains.csv" -o "$domains_csv" 2>/dev/null || echo "Note: Could not update domains database"
|
||||
|
||||
# Try to find domain in CSV file
|
||||
if [ -f "$domains_csv" ]; then
|
||||
# Look for the domain in the CSV (case-insensitive)
|
||||
csv_match=$(grep -i "^${email_domain}," "$domains_csv" | head -1)
|
||||
|
||||
if [ -n "$csv_match" ]; then
|
||||
# Parse CSV: ADDRESS,IMAP,imap port,SMTP,smtp port
|
||||
detected_imap=$(echo "$csv_match" | cut -d',' -f2)
|
||||
imap_port=$(echo "$csv_match" | cut -d',' -f3)
|
||||
detected_smtp=$(echo "$csv_match" | cut -d',' -f4)
|
||||
detected_port=$(echo "$csv_match" | cut -d',' -f5)
|
||||
|
||||
echo ""
|
||||
echo "Found configuration for $email_domain:"
|
||||
echo " IMAP server: $detected_imap"
|
||||
echo " SMTP server: $detected_smtp"
|
||||
echo " SMTP port: $detected_port"
|
||||
echo ""
|
||||
|
||||
read -p "Use these settings? (y/n): " confirm
|
||||
|
||||
if [[ "$confirm" =~ ^[Yy]$ ]]; then
|
||||
imap_server="$detected_imap"
|
||||
smtp_server="$detected_smtp"
|
||||
smtp_port="$detected_port"
|
||||
else
|
||||
# Manual entry
|
||||
echo "Please enter settings manually:"
|
||||
read -p "Enter IMAP server: " imap_server
|
||||
read -p "Enter SMTP server: " smtp_server
|
||||
read -p "Enter SMTP port (465 for SSL/TLS, 587 for STARTTLS) [465]: " smtp_port
|
||||
smtp_port=${smtp_port:-465}
|
||||
fi
|
||||
else
|
||||
# Domain not in CSV, fall back to auto-detection
|
||||
echo "Domain not found in known configurations, attempting auto-detection..."
|
||||
|
||||
# Try to get MX record and extract mail server
|
||||
mx_record=$(dig +short MX "$email_domain" 2>/dev/null | sort -n | head -1 | awk '{print $2}' | sed 's/\.$//')
|
||||
|
||||
@@ -380,6 +422,12 @@ else
|
||||
read -p "Enter SMTP port (465 for SSL/TLS, 587 for STARTTLS) [465]: " smtp_port
|
||||
smtp_port=${smtp_port:-465}
|
||||
fi
|
||||
fi
|
||||
else
|
||||
echo "Could not fetch domains database, using auto-detection..."
|
||||
# Continue with existing auto-detection logic
|
||||
# [Keep the existing auto-detection code as fallback]
|
||||
fi
|
||||
|
||||
# Extract username from email
|
||||
username="${email%%@*}"
|
||||
|
||||
Reference in New Issue
Block a user