107 lines
2.8 KiB
PHP
107 lines
2.8 KiB
PHP
<?php
|
|
/*
|
|
* @AUTHOR: Gurkengewuerz
|
|
* @REVIEW: 05.03.2017
|
|
* @DESCRIPTION: Outlook Autodiscover
|
|
* @SOURCE: https://github.com/biapy/howto.biapy.com/blob/master/various/thunderbird-autoconfig-xml.php
|
|
*
|
|
* DNS:
|
|
* autodiscover.example.com. 219 IN A 101.203.15.106
|
|
*
|
|
* ln -s /var/www/autoconfig/ /var/www/html/
|
|
*
|
|
* NGINX Config:
|
|
* server {
|
|
* listen 443;
|
|
* listen [::]:443;
|
|
* server_name example.com;
|
|
* root /var/www/html/;
|
|
*
|
|
* rewrite /autodiscover/autodiscover.xml$ /autoconfig/autodiscover.php;
|
|
|
|
* location ~ \.php$ {
|
|
* try_files $uri =404;
|
|
* fastcgi_pass unix:/var/run/php/php7.1-fpm.sock;
|
|
* fastcgi_index index.php;
|
|
* fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
|
|
* include fastcgi_params;
|
|
* }
|
|
*}
|
|
*
|
|
*/
|
|
|
|
$data = file_get_contents("php://input");
|
|
preg_match("/\<EMailAddress\>(.*?)\<\/EMailAddress\>/", $data, $matches);
|
|
|
|
$domain = str_replace('autoconfig.', '', $_SERVER['HTTP_HOST']);
|
|
|
|
$default_domain = "mc8051.de";
|
|
$imap_server = 'mail.' . $default_domain;
|
|
$smtp_server = 'mail.' . $default_domain;
|
|
$pop3_server = 'mail.' . $default_domain;
|
|
|
|
$protocols = array(
|
|
'imaps',
|
|
'pop3s',
|
|
'smtps',
|
|
);
|
|
|
|
header('Content-Type: text/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>
|
|
<?php foreach($protocols as $protocol): ?>
|
|
<?php switch($protocol):
|
|
case 'imaps':
|
|
?>
|
|
<Protocol>
|
|
<Type>IMAP</Type>
|
|
<Server><?php echo $imap_server ?></Server>
|
|
<Port>993</Port>
|
|
<SPA>off</SPA>
|
|
<SSL>on</SSL>
|
|
<DomainRequired>off</DomainRequired>
|
|
<AuthRequired>on</AuthRequired>
|
|
<LoginName><?php echo $matches[1]; ?></LoginName>
|
|
</Protocol>
|
|
<?php
|
|
break;
|
|
case 'pop3s':
|
|
?>
|
|
<Protocol>
|
|
<Type>POP3</Type>
|
|
<Server><?php echo $pop3_server ?></Server>
|
|
<Port>995</Port>
|
|
<SPA>off</SPA>
|
|
<SSL>on</SSL>
|
|
<DomainRequired>off</DomainRequired>
|
|
<AuthRequired>on</AuthRequired>
|
|
<LoginName><?php echo $matches[1]; ?></LoginName>
|
|
</Protocol>
|
|
<?php
|
|
break;
|
|
case 'smtps':
|
|
?>
|
|
<Protocol>
|
|
<Type>SMTP</Type>
|
|
<Server><?php echo $smtp_server ?></Server>
|
|
<Port>465</Port>
|
|
<SPA>off</SPA>
|
|
<SSL>on</SSL>
|
|
<DomainRequired>off</DomainRequired>
|
|
<AuthRequired>on</AuthRequired>
|
|
<LoginName><?php echo $matches[1]; ?></LoginName>
|
|
</Protocol>
|
|
<?php
|
|
break;
|
|
?>
|
|
<?php endswitch ?>
|
|
<?php endforeach ?>
|
|
</Account>
|
|
</Response>
|
|
</Autodiscover>
|