added ms-autodiscover
This commit is contained in:
parent
1e27206820
commit
4411a0aaf1
6 changed files with 79 additions and 32 deletions
|
@ -40,6 +40,9 @@ class Responder {
|
|||
case "mail/config-v1.1.xml":
|
||||
$resp = $this->moz_auto_config();
|
||||
break;
|
||||
case "autodiscover":
|
||||
$resp = $this->ms_autodiscover();
|
||||
break;
|
||||
case "none":
|
||||
case "test":
|
||||
case "home":
|
||||
|
@ -70,6 +73,12 @@ class Responder {
|
|||
$response->content = "public/autoconfig.php";
|
||||
return $response;
|
||||
}
|
||||
private function ms_autodiscover(){
|
||||
$response = new Response();
|
||||
$response->content_type = "xml";
|
||||
$response->content = "public/autodiscover.php";
|
||||
return $response;
|
||||
}
|
||||
private function dummy_response(){
|
||||
// Generate a dummy response for testing
|
||||
$response = new Response();
|
||||
|
|
|
@ -2,29 +2,40 @@
|
|||
$conf = Core::$Config["Services"];
|
||||
$data = Core::get_get_data();
|
||||
$email_provided = false;
|
||||
if ($data["path"]) {
|
||||
$display_name = false;
|
||||
$emailaddress = false;
|
||||
if ($data["emailaddress"]) {
|
||||
$email_address = $data["emailaddress"];
|
||||
$display_name = $email_address;
|
||||
$email_provided = true;
|
||||
} else if ($data["path"]) {
|
||||
$query = parse_url($data["path"]);
|
||||
$email = explode("=",$query["query"]);
|
||||
if ($email[0] == "emailaddress") {
|
||||
$email = $email[1];
|
||||
$email_address = explode("=",$query["query"]);
|
||||
if ($email_address[0] == "emailaddress") {
|
||||
$email_address = $email[1];
|
||||
$email_provided = true;
|
||||
if (Core::$Config["LogonDomain"]) {
|
||||
$email = str_ireplace(Core::$Config["Domain"],Core::$Config["LogonDomain"],$email);
|
||||
}
|
||||
$display_name = $email_address;
|
||||
}
|
||||
}
|
||||
if ($email_provided) {
|
||||
if(!Core::$Config["RequireAuthDomain"]) {
|
||||
$email_address = str_ireplace("@".Core::$Config["Domain"],"",$email_address);
|
||||
} else if (Core::$Config["LogonDomain"]) {
|
||||
$email_address = str_ireplace(Core::$Config["Domain"],Core::$Config["LogonDomain"],$email_address);
|
||||
}
|
||||
}
|
||||
?>
|
||||
<clientConfig version="1.1">
|
||||
<emailProvider id="<?php echo Core::$Config["Domain"]?>">
|
||||
<domain><?php echo Core::$Config["Domain"]?></domain>
|
||||
<displayName><?php echo $email_provided ? $email : "%EMAILADDRESS%" ;?></displayName>
|
||||
<displayName><?php echo $email_provided ? $display_name : "%EMAILADDRESS%" ;?></displayName>
|
||||
<?php if($conf["InMail"]){
|
||||
$in = $conf["InMail"]; ?>
|
||||
<incomingServer type="<?php echo strtolower($in["Type"]);?>">
|
||||
<hostname><?php echo $in["Server"];?></hostname>
|
||||
<port><?php echo $in["Port"];?></port>
|
||||
<socketType><?php echo $in["SocketType"];?></socketType>
|
||||
<username><?php echo $email_provided ? $email : "%EMAILADDRESS%";?></username>
|
||||
<username><?php echo $email_provided ? $email_address : "%EMAILADDRESS%";?></username>
|
||||
<authentication><?php echo $in["Authentication"];?></authentication>
|
||||
</incomingServer>
|
||||
<?php } ?>
|
||||
|
@ -34,7 +45,7 @@ if ($data["path"]) {
|
|||
<hostname><?php echo $out["Server"];?></hostname>
|
||||
<port><?php echo $out["Port"];?></port>
|
||||
<socketType><?php echo $out["SocketType"];?></socketType>
|
||||
<username><?php echo $email_provided ? $email : "%EMAILADDRESS%";?></username>
|
||||
<username><?php echo $email_provided ? $email_address : "%EMAILADDRESS%";?></username>
|
||||
<authentication><?php echo $out["Authentication"];?></authentication>
|
||||
</outgoingServer>
|
||||
<?php } ?>
|
||||
|
|
|
@ -1,30 +1,42 @@
|
|||
<?php
|
||||
$conf = Core::$Config["Services"];
|
||||
//get raw POST data so we can extract the email address
|
||||
$data = file_get_contents("php://input");
|
||||
preg_match("/\<EMailAddress\>(.*?)\<\/EMailAddress\>/", $data, $matches);
|
||||
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>server.hostname.com</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>server.hostname.com</Server>
|
||||
<Port>587</Port>
|
||||
<DomainRequired>off</DomainRequired>
|
||||
<LoginName><?php echo $matches[1]; ?></LoginName>
|
||||
<SPA>off</SPA>
|
||||
<Encryption>TLS</Encryption>
|
||||
<AuthRequired>on</AuthRequired>
|
||||
<UsePOPAuth>off</UsePOPAuth>
|
||||
<SMTPLast>off</SMTPLast>
|
||||
</Protocol>
|
||||
<?php if ($conf["InMail"]){
|
||||
$in = $conf["InMail"];?>
|
||||
<Protocol>
|
||||
<Type><?php echo $in["Type"];?></Type>
|
||||
<Server><?php echo $in["Server"];?></Server>
|
||||
<Port><?php echo $in["Port"];?></Port>
|
||||
<DomainRequired><?php echo Core::$Config["RequireAuthDomain"] ? "on" : "off";?></DomainRequired>
|
||||
<LoginName><?php echo $matches[1]; ?></LoginName>
|
||||
<SPA><?php echo $in["SPA"] ? "on" : "off";?></SPA>
|
||||
<SSL><?php echo $in["SocketType"] == "SSL" ? "on" : "off";?></SSL>
|
||||
<AuthRequired><?php echo $in["NoAuthRequired"] ? "off" : "on";?></AuthRequired>
|
||||
</Protocol>
|
||||
<?php }
|
||||
if ($conf["OutMail"]) {
|
||||
$out = $conf["OutMail"];?>
|
||||
<Protocol>
|
||||
<Type><?php echo $out["Type"];?></Type>
|
||||
<Server><?php echo $out["Server"];?></Server>
|
||||
<Port><?php echo $out["Port"];?></Port>
|
||||
<DomainRequired><?php echo Core::$Config["RequireAuthDomain"] ? "on" : "off";?></DomainRequired>
|
||||
<LoginName><?php echo $matches[1]; ?></LoginName>
|
||||
<SPA><?php echo $in["SPA"] ? "on" : "off";?></SPA>
|
||||
<Encryption><?php echo $in["SocketType"];?></Encryption>
|
||||
<AuthRequired><?php echo $in["NoAuthRequired"] ? "off" : "on";?></AuthRequired>
|
||||
<UsePOPAuth><?php echo $in["POPAuth"] ? "on" : "off";?></UsePOPAuth>
|
||||
<SMTPLast><?php echo $in["SMTPLast"] ? "on" : "off";?></SMTPLast>
|
||||
</Protocol>
|
||||
<?php } ?>
|
||||
</Account>
|
||||
</Response>
|
||||
</Autodiscover>
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
; Set the base domain for use with this service
|
||||
Domain = example.com
|
||||
LogonDomain = example.local
|
||||
RequireAuthDomain = false
|
||||
|
||||
; Admin User configuration
|
||||
; not in use yet
|
||||
|
|
4
test-entry.sh
Executable file
4
test-entry.sh
Executable file
|
@ -0,0 +1,4 @@
|
|||
#!/usr/bin/env bash
|
||||
a2enmod rewrite
|
||||
service apache2 stop
|
||||
exec apache2-foreground
|
10
test-server.sh
Normal file
10
test-server.sh
Normal file
|
@ -0,0 +1,10 @@
|
|||
#!/usr/bin/env bash
|
||||
podman run --name davdiscover-test \
|
||||
--rm \
|
||||
-p "8010:80" \
|
||||
-v ./src:/var/www/html/ \
|
||||
-v ./config:/var/www/html/config \
|
||||
-v ./test-entry.sh:/test-entry.sh \
|
||||
--entrypoint "/bin/bash" \
|
||||
php:7.4-apache \
|
||||
/test-entry.sh
|
Loading…
Reference in a new issue