blob: 0cac78a47d7011d23e6194e731f6f9ec4ae69323 (
plain)
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
|
<?php
class IMAPManager
{
protected static $adminclient = null;
public static function getAdminConnection()
{
// exists
if(self::$adminclient != null)
return self::$adminclient;
// create new instance
$server_settings = sfConfig::get('app_server_default');
$imap_settings = $server_settings['imap'];
self::$adminclient = new $imap_settings['client'];
// login
try
{
self::$adminclient->openConnection(
$imap_settings['host'].":".
$imap_settings['port']
);
$success = self::$adminclient->login(
$imap_settings['admin'],
$imap_settings['pass']
);
if(!$success)
throw new Exception("Failed to authenticate on IMAP server.");
} catch (Exception $e) {
LogEntryPeer::log($e->getMessage(), LogEntry::PRIO_ALERT);
}
return self::$adminclient;
}
public static function getAdminUsername()
{
$server_settings = sfConfig::get('app_server_default');
$imap_settings = $server_settings['imap'];
return $imap_settings['admin'];
}
}
?>
|