PHPackages                             horde/mail\_autoconfig - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Mail &amp; Notifications](/categories/mail)
4. /
5. horde/mail\_autoconfig

ActiveLibrary[Mail &amp; Notifications](/categories/mail)

horde/mail\_autoconfig
======================

Mail server autoconfiguration library

v2.0.0(1w ago)1897↑170.6%21LGPL-2.1-onlyPHPPHP ^8.1

Since May 21Pushed 3d ago5 watchersCompare

[ Source](https://github.com/horde/Mail_Autoconfig)[ Packagist](https://packagist.org/packages/horde/mail_autoconfig)[ Docs](https://www.horde.org)[ RSS](/packages/horde-mail-autoconfig/feed)WikiDiscussions FRAMEWORK\_6\_0 Synced today

READMEChangelog (4)Dependencies (24)Versions (21)Used By (1)

Horde Mail\_Autoconfig
======================

[](#horde-mail_autoconfig)

Mail server auto-discovery library for IMAP, POP3, and SMTP.

Overview
--------

[](#overview)

Horde Mail\_Autoconfig discovers mail server configuration (hostnames, ports, TLS settings) for a given email address. It ships two independent codepaths:

- **PSR-4 Modern API** (`Horde\Mail\Autoconfig\Autoconfig`). Uses typed value objects, PSR-18 HTTP Client, injectable DNS resolver plugins.
- **PSR-0 Legacy API** (`Horde_Mail_Autoconfig`) The backward-compatible option. Uses `Horde_Http_Client` and `NetDNS2\Resolver` directly.

Both codepaths coexist in the same package (`src/` and `lib/`). There is no forwarding layer between them. Each is a standalone entry point.

It currently supports IMAP, POP3 and SMTP protocols.

Installation
------------

[](#installation)

```
composer require horde/mail_autoconfig
```

Quick Start (PSR-4)
-------------------

[](#quick-start-psr-4)

```
use Horde\Mail\Autoconfig\Autoconfig;
use Horde\Mail\Autoconfig\Dns\NetDns2Resolver;
use Horde\Mail\Autoconfig\ServerType;
use Horde\Mail\Autoconfig\ValidationMode;

$dns  = new NetDns2Resolver();
$http = /* any PSR-18 ClientInterface */;
$rf   = /* any PSR-17 RequestFactoryInterface */;

$autoconfig = Autoconfig::withBuiltinDrivers($dns, $http, $rf)
    ->withValidation($myValidator, ValidationMode::Next);

$result = $autoconfig->discover('user@example.com');
$imap   = $result->firstOfType(ServerType::Imap);
```

`withBuiltinDrivers()` wires the three built-in drivers (SRV, Thunderbird ISPDB, hostname guessing). `withValidation()` adds optional server validation plugins (only interface and null implementation shipped). Pass your `ValidatorInterface` implementation and a mode:

- **Next** (default): Skip servers that fail validation, keep the rest
- **Fatal**: Throw `AutoconfigException` on the first failure
- **None**: Skip validation entirely

Both methods return new instances; the originals are never modified. Without `withValidation()`, all discovered servers are returned as-is.

### Narrowed Searches

[](#narrowed-searches)

```
// Submission (SMTP/MSA) servers only
$msa = $autoconfig->discoverMsa('user@example.com');

// Incoming mail only, skip POP3
$mail = $autoconfig->discoverMail('user@example.com', noPop3: true);
```

### Working with Results

[](#working-with-results)

```
// First IMAP server, or null
$imap = $result->firstOfType(ServerType::Imap);

// All submission servers as a new DiscoveryResult
$submissionOnly = $result->ofType(ServerType::Submission);
```

### Custom Driver Sets

[](#custom-driver-sets)

When you need to go beyond the defaults:

- Drop a driver
- add your own
- or wire drivers with non-default options

Use the constructor directly:

```
use Horde\Mail\Autoconfig\Driver\SrvDriver;
use Horde\Mail\Autoconfig\Driver\ThunderbirdDriver;

// SRV + Thunderbird only, no hostname guessing
$autoconfig = new Autoconfig(
    new SrvDriver($dns),
    new ThunderbirdDriver($http, $rf),
);

// Chaining still works
$validated = $autoconfig->withValidation($myValidator);
```

Quick Start (PSR-0 Legacy)
--------------------------

[](#quick-start-psr-0-legacy)

```
$autoconfig = new Horde_Mail_Autoconfig();

// Returns the first valid server or false
$imap = $autoconfig->getMailConfig('user@example.com', [
    'auth' => $password,
]);

$smtp = $autoconfig->getMsaConfig('user@example.com', [
    'auth' => $password,
]);
```

Discovery Drivers
-----------------

[](#discovery-drivers)

`withBuiltinDrivers()` registers these drivers in the order shown:

DriverStrategy`SrvDriver`RFC 6186 / RFC 8314 DNS SRV records`ThunderbirdDriver`Mozilla ISPDB autoconfig XML`GuessDriver`Common hostname patterns + DNS A/AAAA validation### SRV Records (RFC 6186 + RFC 8314)

[](#srv-records-rfc-6186--rfc-8314)

Queries these service names per domain:

ServiceTypeTLS`_imaps._tcp`IMAPImplicit TLS (993)`_imap._tcp`IMAPSTARTTLS (143)`_pop3s._tcp`POP3Implicit TLS (995)`_pop3._tcp`POP3STARTTLS (110)`_submissions._tcp`SubmissionImplicit TLS (465)`_submission._tcp`SubmissionSTARTTLS (587)### Thunderbird ISPDB

[](#thunderbird-ispdb)

Tries these URLs in order (all HTTPS):

1. `https://autoconfig.{domain}/mail/config-v1.1.xml?emailaddress={email}`
2. `https://{domain}/.well-known/autoconfig/mail/config-v1.1.xml`
3. `https://autoconfig.thunderbird.net/v1.1/{domain}`

### Hostname Guessing

[](#hostname-guessing)

Tries common prefixes (`smtp.`, `mail.`, `imap.`, `pop.`, `pop3.`) against each domain and keeps only hostnames that resolve in DNS.

Key Differences: PSR-4 vs PSR-0
-------------------------------

[](#key-differences-psr-4-vs-psr-0)

AspectPSR-4 (`src/`)PSR-0 (`lib/`)Return type`DiscoveryResult` (all servers)First valid server or `false`ValidationCaller's responsibilityBuilt-in (connects to test)HTTP clientPSR-18 `ClientInterface``Horde_Http_Client`DNS resolver`DnsResolverInterface` (injectable)`NetDNS2\Resolver` (direct)TLS modes`TlsMode` enum`'tls'` string or `null`Server types`ServerType` enumClass hierarchyRFC 8314`_submissions._tcp` supportedNot supportedISPDB URL`autoconfig.thunderbird.net``autoconfig.thunderbird.net`System Requirements
-------------------

[](#system-requirements)

- PHP ^8.1
- ext-SimpleXML
- `horde/mail` ^3
- `mikepultz/netdns2` ^2.0 for the DNS probes
- A PSR-18 HTTP client and PSR-17 request factory (for `src/` drivers)

Testing
-------

[](#testing)

```
# Unit tests
phpunit --testsuite unit

# Full suite (integration tests need test/conf.php)
phpunit
```

Integrator and Developer Guides
-------------------------------

[](#integrator-and-developer-guides)

See [doc/UPGRADING.md](doc/UPGRADING.md) for detailed migration instructions from the PSR-0 API to the PSR-4 API.

See [doc/EXTENDING.md](doc/UPGRADING.md) for how to add validation of found configs or additional check drivers.

License
-------

[](#license)

LGPL-2.1-only -- see [LICENSE](LICENSE) for details.

Links
-----

[](#links)

- **GitHub**: [https://github.com/horde/Mail\_Autoconfig](https://github.com/horde/Mail_Autoconfig)
- **Packagist**: [https://packagist.org/packages/horde/mail\_autoconfig](https://packagist.org/packages/horde/mail_autoconfig)
- **Issues**: [https://github.com/horde/Mail\_Autoconfig/issues](https://github.com/horde/Mail_Autoconfig/issues)

###  Health Score

60

—

FairBetter than 98% of packages

Maintenance99

Actively maintained with recent releases

Popularity22

Limited adoption so far

Community26

Small or concentrated contributor base

Maturity81

Battle-tested with a long release history

 Bus Factor1

Top contributor holds 58.5% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~340 days

Recently: every ~333 days

Total

14

Last Release

7d ago

Major Versions

1.0.3 → 2.0.0alpha22021-02-24

PHP version history (5 changes)1.0.0beta1PHP &gt;=5.3.0,&lt;=6.0.0alpha1

1.0.3PHP &gt;=5.3.0,&lt;=8.0.0alpha1

2.0.0alpha2PHP ^7

v2.0.0alpha4PHP ^7.4 || ^8

v2.0.0alpha7PHP ^8.1

### Community

Maintainers

![](https://www.gravatar.com/avatar/c943a083635c28520599075eaea7ede2d743b7697b76e84d6bdc37e52cc8249b?d=identicon)[yunosh](/maintainers/yunosh)

![](https://www.gravatar.com/avatar/c931cd02664859360478593450d6c473a05bb12b209dfacfc534cd13257cc7ef?d=identicon)[ralflang](/maintainers/ralflang)

![](https://www.gravatar.com/avatar/e4f6c6771993db2ed500959b42353f6cf6a2ca0406d9617f7ae680f4504faa4a?d=identicon)[horde](/maintainers/horde)

![](https://www.gravatar.com/avatar/a7767adb66b45f2f05bcd44d49bc4e67efacd9ce05b161ce2d481d5dd6af025c?d=identicon)[mrubinsk](/maintainers/mrubinsk)

![](https://www.gravatar.com/avatar/816e2b926f25f8cd2939054c7a7173011b4303d690e25ab61bf33cf8c7cf71ae?d=identicon)[tdannhauer](/maintainers/tdannhauer)

---

Top Contributors

[![yunosh](https://avatars.githubusercontent.com/u/379318?v=4)](https://github.com/yunosh "yunosh (55 commits)")[![ralflang](https://avatars.githubusercontent.com/u/646976?v=4)](https://github.com/ralflang "ralflang (25 commits)")[![slusarz](https://avatars.githubusercontent.com/u/381003?v=4)](https://github.com/slusarz "slusarz (9 commits)")[![mrubinsk](https://avatars.githubusercontent.com/u/66822?v=4)](https://github.com/mrubinsk "mrubinsk (4 commits)")[![TDannhauer](https://avatars.githubusercontent.com/u/6716033?v=4)](https://github.com/TDannhauer "TDannhauer (1 commits)")

---

Tags

smtpimapautodiscovery

### Embed Badge

![Health badge](/badges/horde-mail-autoconfig/health.svg)

```
[![Health](https://phpackages.com/badges/horde-mail-autoconfig/health.svg)](https://phpackages.com/packages/horde-mail-autoconfig)
```

###  Alternatives

[horde/imp

Webmail application

261.3k](/packages/horde-imp)[horde/horde

Horde base application

583.0k71](/packages/horde-horde)[horde/kronolith

Calendar and scheduling application

101.5k5](/packages/horde-kronolith)[jason-munro/cypht

Lightweight Open Source webmail written in PHP and JavaScript

1.6k157.9k](/packages/jason-munro-cypht)[horde/imap_client

IMAP client library

275.5k20](/packages/horde-imap-client)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
