Advertisement
jracing

autodiscover.php

Nov 15th, 2024 (edited)
30
0
Never
1
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.60 KB | None | 0 0
  1. <?php
  2. $postData = file_get_contents("php://input"); //Autodiscover requests are HTTP posts with XML content
  3. $xml = simplexml_load_string($postData);
  4. $user = $xml->Request->EMailAddress; //copy the email address from the request into a variable
  5. $domain = substr($user, strpos($user, '@') + 1); // get the domain name from the email address
  6.  
  7. //set Content-Type
  8. header("Content-Type: application/xml"); ?>
  9. <?php echo '<?xml version="1.0" encoding="utf-8" ?>'; ?>
  10.  
  11. <Autodiscover xmlns="http://schemas.microsoft.com/exchange/autodiscover/responseschema/2006">
  12.   <Response xmlns="http://schemas.microsoft.com/exchange/autodiscover/outlook/responseschema/2006a">
  13.    <Account>
  14.       <AccountType>email</AccountType>
  15.       <Action>settings</Action>
  16.       <Protocol>
  17.          <Type>IMAP</Type>
  18.          <Server>mail.example.tld</Server>
  19.          <Port>993</Port>
  20.          <DomainRequired>on</DomainRequired>
  21.          <Domain><?php echo $domain; ?></Domain>
  22.          <LoginName><?php echo $user; ?></LoginName>
  23.          <SPA>off</SPA>
  24.          <SSL>on</SSL>
  25.          <Encryption>TLS</Encryption>
  26.          <AuthRequired>on</AuthRequired>
  27.       </Protocol>
  28.       <Protocol>
  29.          <Type>SMTP</Type>
  30.          <Server>mail.example.tld</Server>
  31.          <Port>587</Port>
  32.          <DomainRequired>on</DomainRequired>
  33.          <Domain><?php echo $domain; ?></Domain>
  34.          <LoginName><?php echo $user; ?></LoginName>
  35.          <SPA>off</SPA>
  36.          <Encryption>TLS</Encryption>
  37.          <AuthRequired>on</AuthRequired>
  38.          <SMTPLast>on</SMTPLast>
  39.       </Protocol>
  40.    </Account>
  41. </Response>
  42. </Autodiscover>
  43.  
Advertisement
Comments
Add Comment
Please, Sign In to add comment
Advertisement