Last active
January 8, 2024 06:16
-
-
Save Nilpo/50511b736dc88dd9d915e14bbd3447bd to your computer and use it in GitHub Desktop.
Autodiscover.xml generator in PHP for Outlook (and other) mail client configuration.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
//get raw POST data so we can extract the email address | |
$data = file_get_contents("php://input"); | |
preg_match("/\<EMailAddress\>(.*?)\<\/EMailAddress\>/", $data, $matches); | |
//set Content-Type | |
header("Content-Type: application/xml"); | |
echo '<?xml version="1.0" encoding="utf-8" ?>'; ?> | |
<Autodiscover xmlns="http://schemas.microsoft.com/exchange/autodiscover/responseschema/2006"> | |
<Response xmlns="http://schemas.microsoft.com/exchange/autodiscover/outlook/responseschema/2006a"> | |
<Account> | |
<AccountType>email</AccountType> | |
<Action>settings</Action> | |
<Protocol> | |
<Type>IMAP</Type> | |
<Server>example.com</Server> | |
<Port>143</Port> | |
<DomainRequired>off</DomainRequired> | |
<LoginName><?php echo $matches[1]; ?></LoginName> | |
<SPA>off</SPA> | |
<SSL>auto</SSL> | |
<AuthRequired>on</AuthRequired> | |
</Protocol> | |
<Protocol> | |
<Type>POP3</Type> | |
<Server>example.com</Server> | |
<Port>995</Port> | |
<DomainRequired>off</DomainRequired> | |
<LoginName><?php echo $matches[1]; ?></LoginName> | |
<SPA>off</SPA> | |
<SSL>on</SSL> | |
<AuthRequired>on</AuthRequired> | |
</Protocol> | |
<Protocol> | |
<Type>SMTP</Type> | |
<Server>example.com</Server> | |
<Port>587</Port> | |
<DomainRequired>off</DomainRequired> | |
<LoginName><?php echo $matches[1]; ?></LoginName> | |
<SPA>off</SPA> | |
<Encryption>TLS</Encryption> | |
<AuthRequired>on</AuthRequired> | |
<UsePOPAuth>off</UsePOPAuth> | |
<SMTPLast>off</SMTPLast> | |
</Protocol> | |
</Account> | |
</Response> | |
</Autodiscover> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
RewriteEngine On | |
# Blocks all autodiscover requests to prevent 404 errors in the log | |
#RewriteCond %{REQUEST_URI} ^/autodiscover/autodiscover.xml [NC] | |
#RewriteRule .* - [F,L] | |
RewriteCond %{REQUEST_FILENAME} -s [OR] | |
RewriteCond %{REQUEST_FILENAME} -l [OR] | |
RewriteCond %{REQUEST_FILENAME} -d | |
RewriteRule ^.*$ - [NC,L] | |
RewriteRule ^.*$ autodiscover.php [NC,L] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
_autodiscover._tcp.example.com. SRV 10 10 443 autodiscover.example.com. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="utf-8"?> | |
<Autodiscover xmlns="https://schemas.microsoft.com/exchange/autodiscover/outlook/requestschema/2006"> | |
<Request> | |
<EMailAddress>[email protected]</EMailAddress> | |
<AcceptableResponseSchema>https://schemas.microsoft.com/exchange/autodiscover/outlook/responseschema/2006a</AcceptableResponseSchema> | |
</Request> | |
</Autodiscover> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="utf-8" ?> | |
<Autodiscover xmlns="http://schemas.microsoft.com/exchange/autodiscover/responseschema/2006"> | |
<Response xmlns="http://schemas.microsoft.com/exchange/autodiscover/outlook/responseschema/2006a"> | |
<Account> | |
<AccountType>email</AccountType> | |
<Action>settings</Action> | |
<Protocol> | |
<Type>IMAP</Type> | |
<Server>example.com</Server> | |
<Port>143</Port> | |
<DomainRequired>off</DomainRequired> | |
<LoginName>[email protected]</LoginName> | |
<SPA>off</SPA> | |
<SSL>auto</SSL> | |
<AuthRequired>on</AuthRequired> | |
</Protocol> | |
<Protocol> | |
<Type>POP3</Type> | |
<Server>example.com</Server> | |
<Port>995</Port> | |
<DomainRequired>off</DomainRequired> | |
<LoginName>[email protected]</LoginName> | |
<SPA>off</SPA> | |
<SSL>on</SSL> | |
<AuthRequired>on</AuthRequired> | |
</Protocol> | |
<Protocol> | |
<Type>SMTP</Type> | |
<Server>example.com</Server> | |
<Port>587</Port> | |
<DomainRequired>off</DomainRequired> | |
<LoginName>[email protected]</LoginName> | |
<SPA>off</SPA> | |
<Encryption>TLS</Encryption> | |
<AuthRequired>on</AuthRequired> | |
<UsePOPAuth>off</UsePOPAuth> | |
<SMTPLast>off</SMTPLast> | |
</Protocol> | |
</Account> | |
</Response> | |
</Autodiscover> |
nslookup -q=CNAME autodiscover.domain.com
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
nslookup -q=srv _autodiscover._tcp.example.com