Sign up ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Is it possible to set up an Autodiscover.xml that points an iPhone (or other ActiveSync compatible device) to the server automatically so after putting in your email and password it is instantly set up?

To set up iPhones with Google Apps for Business, you can select Exchange ActiveSync as the account type, put in your Google Apps email and password, and then after hitting next and waiting a bit, put in the server field. This will sync your Contacts, Calendars, and push email with your iPhone.

I have an autodiscover.xml working right now that automatically configures Outlook to use the Google Apps IMAP and SMTP settings, but I can't seem to do the same for ActiveSync devices.

I have tried to do something similar to this:

 Open Source Autodiscover implementation in PHP.

 Version: 1.0
 Tested with:
    - Microsoft Exchange Remote Connectivity Analyzer (1.3)
    - iOS 4.3.5
    - Outlook 2010 (SP0)
    - Android 2.3.3

 Allows auto configuration of ActiveSync and Outlook (or any other MUA that has
 autodiscover support).

 Example Apache vhost configuration (SSL is required for Autodiscover):


            SSLEngine on
            SSLCertificateFile      /etc/apache/ssl/certs/
            SSLCertificateKeyFile   /etc/apache/ssl/private/

        # Force all requests to lowercase. Different MUAs, mobile devices etc
        # request the Autodiscover URL in different cases.
            RewriteEngine On
            RewriteMap lc int:tolower
            RewriteCond %{REQUEST_URI} [A-Z]
            RewriteRule (.*) ${lc:$1} [R=301,L]

            DocumentRoot /var/www/autodiscover/htdocs
            <Directory />
                    Options +FollowSymLinks -Indexes
                    AllowOverride Options Indexes Limit FileInfo AuthConfig

             Alias /autodiscover/autodiscover.xml /var/www/autodiscover/htdocs/autodiscover.php

            ErrorLog /var/www/autodiscover/logs/error.log
            CustomLog /var/www/autodiscover/logs/access.log combined

  Copyright (C) 2011 David Ramsden

  This software is provided 'as-is', without any express or implied
  warranty.  In no event will the authors be held liable for any damages
  arising from the use of this software.

  Permission is granted to anyone to use this software for any purpose,
  including commercial applications, and to alter it and redistribute it
  freely, subject to the following restrictions:

  1. The origin of this software must not be misrepresented; you must not
     claim that you wrote the original software. If you use this software
     in a product, an acknowledgment in the product documentation would be
     appreciated but is not required.
  2. Altered source versions must be plainly marked as such, and must not be
     misrepresented as being the original software.
  3. This notice may not be removed or altered from any source distribution.

  David Ramsden david {at} 0wned {dot} it

/*** Begin Configuration ***/
// ActiveSync URL.
$_CONFIG['MobileSync']['Url'] = "";

// IMAP configuration settings.
$_CONFIG['IMAP']['Server'] = "";
$_CONFIG['IMAP']['Port'] = "993";
$_CONFIG['IMAP']['SSL'] = "on";
$_CONFIG['IMAP']['SPA'] = "off";
$_CONFIG['IMAP']['AuthRequired'] = "on";

// SMTP configuration settings.
$_CONFIG['SMTP']['Server'] = "";
$_CONFIG['SMTP']['Port'] = "25";
$_CONFIG['SMTP']['SSL'] = "on";
$_CONFIG['SMTP']['SPA'] = "off";
$_CONFIG['SMTP']['AuthRequired'] = "on";
/*** End Configuration ***/

// For other supported protocols and more protocol settings, see:

// Get contents of request made to Autodiscover.
$request = file_get_contents("php://input");

// XML document heading.
header("Content-Type: text/xml");
echo "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n";

// Get the schema from the request.
preg_match("/\<AcceptableResponseSchema\>(.*?)\<\/AcceptableResponseSchema\>/", $request, $schema);
// Determine the type of device requesting Autodiscover.
if (preg_match("/\/mobilesync\//", $schema[1]))
    // Mobile device.
    preg_match("/\<EMailAddress\>(.*?)\<\/EMailAddress\>/", $request, $email_address);
        <Autodiscover xmlns="">
            <Response xmlns="<? echo $schema[1]; ?>">
                    <DisplayName><? echo $email_address[1]; ?></DisplayName>
                    <EMailAddress><? echo $email_address[1]; ?></EMailAddress>
                            <Url><? echo $_CONFIG['MobileSync']['Url']; ?></Url>
                            <Name><? echo $_CONFIG['MobileSync']['Url']; ?></Name>
else if (preg_match("/\/outlook\//", $schema[1]))
    // MUA (mail client).
        <Autodiscover xmlns="">
            <Response xmlns="<? echo $schema[1]; ?>">
                    // Loop through each configured protocol.
                    while(list($protocol, $settings) = each($_CONFIG))
                        // Skip ActiveSync protocol.
                        if ($protocol == "MobileSync") continue;
                            <Type><? echo $protocol; ?></Type>
                        // Loop through each setting for this protocol.
                        while(list($setting, $value) = each($settings))
                            echo "\t\t\t\t\t\t\t<$setting>$value</$setting>\n";
    // Unknown.
    list($usec, $sec) = explode(' ', microtime());
        <Autodiscover xmlns="">
                <Error Time="<? echo date('H:i:s', $sec) . substr($usec, 0, strlen($usec) - 2); ?>" Id="2477272013">
                    <Message>Invalid Request</Message>
                    <DebugData />

from here:

I put as the server name and URL. This causes the iPhone to take a little longer to set up than usual like it's thinking real hard about it but ultimately decides that's not what it's looking for and asks for the server anyway.

share|improve this question
I'm not sure I'm visiting a link on a domain like and an extension of .php_.txt... – ceejayoz Sep 20 '13 at 15:18

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.