Support for Thunderbird-style autoconfiguration

Okay, since this has been floating around for quite a while, I'd like to make it an official feature request. :)

While Virtualmin users can of course set this up manually/individually, It'd be great to include automatic email client autoconfiguration support in Thunderbird style into Virtualmin. To do that for domain example.com, one needs to:

  • The autoconfig file needs to be served on the subdomain autoconfig.example.com.
  • That domain needs to serve a file with the URL http://autoconfig.example.com/mail/config-v1.1.xml?emailaddress=user@example.com.
  • The contents of the file I listed below

Idea would be to create an Apache RewriteRule to map the autoconfig domain to some central autoconfig storage URL, like it is done with the "admin" and "webmail" subdomains.

Config file contents example:

<?xml version="1.0" encoding="UTF-8"?>
 
<clientConfig version="1.1">
  <emailProvider id="example.com">
    <domain>example.com</domain>
    <displayName>Example Mail</displayName>
    <displayShortName>Example</displayShortName>
    <incomingServer type="imap">
      <hostname>mail.example.com</hostname>
      <port>993</port>
      <socketType>SSL</socketType>
      <authentication>password-cleartext</authentication>
      <username>%EMAILADDRESS%</username>
    </incomingServer>
    <outgoingServer type="smtp">
      <hostname>mail.example.com</hostname>
      <port>465</port>
      <socketType>SSL</socketType>
      <authentication>password-cleartext</authentication>
      <username>%EMAILADDRESS%</username>
    </outgoingServer>
  </emailProvider>
</clientConfig>

Full details about the file can be found here: https://developer.mozilla.org/en-US/docs/Thunderbird/Autoconfiguration/F...

Issues that I see is the username format, which can be quite versatile per virtual server, and the connection type (SSL, STARTLS, port numbers). Maybe that information can be fetched from somewhere, or entered in the Template page for Email.

The username supports the placeholders "%EMAILADDRESS%" and "%EMAILLOCALPART%". If the Virtual Server uses a different scheme for naming users, like "user@example" without ".com", some script that does the correct conversion is required.

Status: 
Closed (fixed)

Comments

That sounds like a cool feature, and not too hard to implement.

There probably isn't even any need for a rewrite rule - instead autoconfig.example.com could just be another ServerAlias for example.com in the Apache config, and /mail/config-v1.1.xml could be served by a trivial CGI script that outputs the appropriate XML.

Very nice!

Without the rewrite rule the CGI script would have to be copied to each domain that uses autoconfig. Works of course, I figured having a central script instance could prevent that.

You're right... If you make this into a Feature that can be turned on or off, similar to AWStats, it's probably best to copy the CGI script into each domain, and make the "autoconfig" simply a ServerAlias. Maybe make a RedirectMatch to point the URL path to the right file system path, like with AWStats.

Here's my PHP script that I'm currently using. I re-write the autoconfig subdomain to a central domain and keep the query string intact.

RewriteCond %{HTTP_HOST} =autoconfig.domain.de
RewriteRule ^/mail/config-v1\.1\.xml http://centraldomain.de/mail/config-v1.1.php [L,R=301,NE,QSA]
<div class="codeblock"><pre><code><span style="color: #000000"><span style="color: #0000BB"><?php<br /></span><span style="color: #007700">&</span><span style="color: #FF8000">#10;header(&#039;Content-type: application/xml&#039;);&#10;echo &#039;&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;<br /></span><span style="color: #0000BB">?></span></span></code></pre></div>';
$email = $_GET["emailaddress"];
$parts = explode("@", $email);
$domain = $parts[1];
?>
 
<clientConfig version="1.1">
  <emailProvider id="<div class="codeblock"><pre><code><span style="color: #000000"><span style="color: #0000BB"><?php<br /> </span><span style="color: #007700">echo </span><span style="color: #0000BB">$domain</span><span style="color: #007700">;<br /></span><span style="color: #0000BB">?></span></span></code></pre></div>">
    <domain><div class="codeblock"><pre><code><span style="color: #000000"><span style="color: #0000BB"><?php<br /> </span><span style="color: #007700">echo </span><span style="color: #0000BB">$domain</span><span style="color: #007700">;<br /></span><span style="color: #0000BB">?></span></span></code></pre></div></domain>
    <displayName><div class="codeblock"><pre><code><span style="color: #000000"><span style="color: #0000BB"><?php<br /> </span><span style="color: #007700">echo </span><span style="color: #0000BB">$domain</span><span style="color: #007700">;<br /></span><span style="color: #0000BB">?></span></span></code></pre></div> Email</displayName>
    <displayShortName><div class="codeblock"><pre><code><span style="color: #000000"><span style="color: #0000BB"><?php<br /> </span><span style="color: #007700">echo </span><span style="color: #0000BB">$domain</span><span style="color: #007700">;<br /></span><span style="color: #0000BB">?></span></span></code></pre></div></displayShortName>
    <incomingServer type="imap">
      <hostname>mail.<div class="codeblock"><pre><code><span style="color: #000000"><span style="color: #0000BB"><?php<br /> </span><span style="color: #007700">echo </span><span style="color: #0000BB">$domain</span><span style="color: #007700">;<br /></span><span style="color: #0000BB">?></span></span></code></pre></div></hostname>
      <port>993</port>
      <socketType>SSL</socketType>
      <authentication>password-cleartext</authentication>
      <username>%EMAILADDRESS%</username>
    </incomingServer>
    <outgoingServer type="smtp">
      <hostname>mail.<div class="codeblock"><pre><code><span style="color: #000000"><span style="color: #0000BB"><?php<br /> </span><span style="color: #007700">echo </span><span style="color: #0000BB">$domain</span><span style="color: #007700">;<br /></span><span style="color: #0000BB">?></span></span></code></pre></div></hostname>
      <port>465</port>
      <socketType>SSL</socketType>
      <authentication>password-cleartext</authentication>
      <username>%EMAILADDRESS%</username>
    </outgoingServer>
  </emailProvider>
</clientConfig>

I have just finished implementing this, for inclusion in the next (3.98) Virtualmin release. You will be able to enable or disable it for all virtual servers (with mail and a website enabled) at once.

Very nice! I'm gonna test that, even though I tinkered a manual solution for myself meanwhile.

Automatically closed -- issue fixed for 2 weeks with no activity.