Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions src/Autodiscover.php
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,24 @@ public function discover()
$result = $this->trySRVRecord();
}

if ($result === false and is_array($this->redirect) && array_key_exists('redirectAddr', $this->redirect)) {
// redirect was found. Try again with the new address
$this->email = $this->redirect['redirectAddr'];
$this->username = $this->redirect['redirectAddr'];
$this->setTLD();
$result = $this->discover();
}

if ($result === false and is_array($this->redirect) && array_key_exists('redirectUrl', $this->redirect)) {
// redirect was found. Try again with the new URL
// https://stackoverflow.com/questions/27745/getting-parts-of-a-url-regex
$regExp = "/^(.*:)//([A-Za-z0-9\-\.]+)(:[0-9]+)?(.*)$/";
if (preg_match($regExp, $this->redirect['redirectUrl'], $matches)) {
$this->tld = $matches[2];
$result = $this->discover();
}
}

if ($result === false) {
throw new \RuntimeException('Autodiscovery failed.');
}
Expand Down