| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546 |
- <?php
- class Imap {
- private $server = NULL;
- private $username = NULL;
- private $password = NULL;
- private $mailbox = NULL;
- private $folders = NULL;
- public function __construct($server, $username, $password) {
- $this->server = $server;
- $this->username = $username;
- $this->password = $password;
- $this->mailbox = imap_open($this->server . 'INBOX', $this->username, $this->password) or error('Failed to connect to IMAP');
- }
- public function changeFolder($folder) {
- imap_reopen($this->mailbox, $this->server . $folder);
- }
- public function listFolders() {
- $newFolders = array();
- $folders = imap_list($this->mailbox, $this->server, "*");
- foreach($folders as $folder) {
- $newFolders[] = preg_replace('/(\{(.*)\})(.*)/', '${3}', $folder);
- }
- $this->folders = $newFolders;
- }
- public function getFolders() {
- return $this->folders;
- }
- public function getServer() {
- return $this->server;
- }
- public function getMailbox() {
- return $this->mailbox;
- }
- }
|