Download the PHP package accountdesk/mail-autodetect without Composer
On this page you can find all versions of the php package accountdesk/mail-autodetect. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download accountdesk/mail-autodetect
More information about accountdesk/mail-autodetect
Files in accountdesk/mail-autodetect
Package mail-autodetect
Short Description Auto-detect IMAP and SMTP mail server settings for any domain
License MIT
Homepage https://github.com/accountdesk/mail-autodetect
Informations about the package mail-autodetect
Mail-AutoDetect
Mail server discovery on autopilot
PHP library for automatic detection of IMAP and SMTP server settings for any domain.
Installation
Option 1: Composer
Option 2: Manual
Copy src/AutoDetector.php into your project and include it:
Requirements:
- PHP >= 8.1
- ext-curl
- ext-simplexml
Usage
Output:
Configuration
Logging (PSR-3)
Log levels:
info: Start/end of detection, threshold reacheddebug: Individual strategies, DNS/HTTP requests, cache hitswarning: HTTP/DNS errors
Caching
DNS and HTTP results are automatically cached (in-memory per request). Multiple queries for the same domain won't trigger duplicate requests.
Detection Strategies
The library uses multiple strategies in descending reliability:
| # | Strategy | Score | Description |
|---|---|---|---|
| 1 | Mozilla ISPDB | 95 | Thunderbird autoconfig database |
| 2 | Known MX | 92 | Known providers (Gmail, Outlook, etc.) via MX pattern |
| 3 | Microsoft Autodiscover | 92 | Exchange/Office 365 (requires email) |
| 4 | DNS SRV | 90 | RFC 6186 service records |
| 5 | Domain Autoconfig | 90 | autoconfig.domain/mail/config-v1.1.xml |
| 6 | MX Heuristic | 75-80 | MX record + SPF parsing + TCP check |
| 7 | Standard Hosts | 55-70 | imap.domain, smtp.domain + TCP check |
Score calculation:
- Servers found by multiple sources get +5 bonus per additional source
- Reverse DNS mismatch on guessed hosts: -15 points
- Maximum: 100 points
Response Format
Each candidate contains:
| Field | Type | Description |
|---|---|---|
host |
string | Server hostname |
port |
int | Port (993, 465, 587, ...) |
ssl |
string | ssl, starttls, or plain |
auth |
string|null | Auth method (if known) |
source |
string | Primary source |
sources |
array | All sources that found this server |
score |
int | Confidence score (0-100) |
match_count |
int | Number of sources |
Security Considerations
Important: This library detects mail server configurations but does NOT validate them.
Before using detected settings with real credentials:
- Always confirm with the user - Show the detected hostname/port and ask for explicit confirmation
- Don't auto-connect - Never automatically test connections with real passwords
- Validate the domain - Ensure the detected hosts belong to the expected domain
Example secure implementation:
Why this matters: A malicious domain could configure autoconfig/autodiscover to point to an attacker-controlled server, potentially capturing credentials.
License
MIT
Testing
This library uses static analysis (Mago) instead of unit tests. Network-dependent libraries like this are better validated through real-world usage than mocked tests.
All versions of mail-autodetect with dependencies
ext-curl Version *
ext-simplexml Version *