-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.php
59 lines (51 loc) · 1.7 KB
/
index.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
<?php
require('vendor/autoload.php');
// Usages
use Discover\Base\Server,
Discover\Base\ServerType,
Discover\Base\SocketType,
Discover\Base\Authentication,
Discover\Base\MailInformation,
Discover\Autoconfig\Autoconfig,
Discover\Autodiscover\Autodiscover;
// Build our default server config
// TODO: Link this to ISPConfig
$imap = Server::factory(ServerType::IMAP, SocketType::SSL, Authentication::PLAIN, 'imap.omniasoft.nl', '%EMAILADDRESS%');
$smtp = Server::factory(ServerType::SMTP, SocketType::SSL, Authentication::PLAIN, 'smtp.omniasoft.nl', '%EMAILADDRESS%');
$pop = Server::factory(ServerType::POP, SocketType::SSL, Authentication::PLAIN, 'pop.omniasoft.nl', '%EMAILADDRESS%');
$mailInformation = new MailInformation;
$mailInformation->name = 'Omniasoft';
$mailInformation->domain = 'omniasoft.nl';
$mailInformation->servers = [$imap, $smtp, $pop];
// Check what to do
$request = $_SERVER['SCRIPT_URL'];
switch ($request)
{
case Autoconfig::REQUEST:
// There email adress
$email = $_GET['emailaddress'];
// Create root document
$autoconfig = new Autoconfig();
$autoconfig->translate($mailInformation);
// Output
header("Content-Type: text/xml; charset=utf-8");
die($autoconfig);
break;
case Autodiscover::REQUEST:
// There email adress
//get raw POST data so we can extract the email address
// TODO: Fancy XML parsing
$data = file_get_contents("php://input");
preg_match("/\<EMailAddress\>(.*?)\<\/EMailAddress\>/", $data, $matches);
$email = $matches[1];
// Create root document
$autodiscover = new Autodiscover($email);
$autodiscover->translate($mailInformation);
// Output
header("Content-Type: text/xml");
die($autodiscover);
break;
default:
die('Wrong...');
break;
}