Mainos / Advertisement:

Ero sivun ”Autoconfig + Autodiscover” versioiden välillä

Kohteesta Taisto
Siirry navigaatioon Siirry hakuun
(Ak: Uusi sivu: Autoconfig ja Autodiscoveryn ideana helpottaa sähköpostiasetusten määrittämisen sähköpostiohjelmille kuten Outlook tai Thunderbird. Tässä pieni ohje miten saat toimimaan...)
(ei mitään eroa)

Versio 13. lokakuuta 2017 kello 19.27

Autoconfig ja Autodiscoveryn ideana helpottaa sähköpostiasetusten määrittämisen sähköpostiohjelmille kuten Outlook tai Thunderbird.

Tässä pieni ohje miten saat toimimaan nämä palvelimellasi.

Vaatimukset:

  • Webserver, Nginx tai Apache2. Tämä ohje tehty Nginx:lle.
  • PHP, PHP-XML
  • autodiscover käytetään HTTPS:ää, joten SSL-sertifikaatti vaadittu, kuten Let's Encrypt.

Konfiguroi nimipalvelintietueet:

  • autoconfig.example.org osoittamaan webpalvelimellesi
  • autodiscover.example.org osoittamaan webpalvelimellesi

Konfiguroi Nginx:ään esimerkiksi:

Tee myös HTTPS-puolelle vastaava konfiguraatio

server {
        listen *:80;
        server_name autoconfig.* autodiscovery.*;

        location '/.well-known/acme-challenge' {
        default_type "text/plain";
        root        /opt/letsencrypt;
        }

        root /var/www/autodiscover/;

        location /mail/config-v1.1.xml {
                try_files $uri /autoconfig.php?$args;
                rewrite ^(.+)$ /autoconfig.php?$1 last;
        }


        location ~ \.php$ {
                try_files $uri =404;
                fastcgi_pass unix:/var/run/php/php7.0-fpm.sock;
                fastcgi_index index.php;
                fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
                include fastcgi_params;
        }

        access_log /var/log/nginx/access_log;
        error_log /var/log/nginx/error_log;
}

Luo autoconfig.php tiedosto ja tallenna se webroottiin.

<?php
header ("Content-Type:text/xml");
$domain = $_SERVER["HTTP_HOST"];
$mail = htmlspecialchars($_GET['emailaddress']);
$host = substr(strrchr($mail, "@"), 1);
echo <<<EOP
<?xml version="1.0"?>
<clientConfig version="1.1">
    <emailProvider id="{$domain}">
        <domain>{$domain}</domain>
        <displayName>{$mail}</displayName>
        <displayShortName>{$mail}</displayShortName>
        <incomingServer type="imap">
            <hostname>{$host}</hostname>
            <port>143</port>
            <socketType>STARTTLS</socketType>
            <username>{$mail}</username>
            <authentication>password-cleartext</authentication>
        </incomingServer>
        <outgoingServer type="smtp">
            <hostname>{$host}</hostname>
            <port>587</port>
            <socketType>STARTTLS</socketType>
            <authentication>password-cleartext</authentication>
            <username>{$mail}</username>
        </outgoingServer>
    </emailProvider>
</clientConfig>
EOP;

Ja tämä autodiscover.php tiedostoon

<?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");
$host = substr(strrchr($matches[1], "@"), 1);
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><?php echo $host; ?></Server>
                <Port>993</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><?php echo $host; ?></Server>
                <Port>587</Port>
                <DomainRequired>off</DomainRequired>
                <LoginName><?php echo $matches[1]; ?></LoginName>
                <SPA>off</SPA>
                <AuthRequired>on</AuthRequired>
                <UsePOPAuth>off</UsePOPAuth>
                <SMTPLast>off</SMTPLast>
                <Encryption>TLS</Encryption>
                <TLS>on</TLS>
            </Protocol>
        </Account>
    </Response>
</Autodiscover>
Mainos / Advertisement: