- <?php
- class Mail extends BaseObject {
- var $server;
- var $port;
- var $user_name;
- var $password;
- var $pop3;
- var $imap;
- var $imap_obj;
- var $pop3_obj;
- var $folder;
- Function Mail() {
- $this->BaseObject( 'Mail' );
- $this->server = 'localhost';
- $this->server_port = 143;
- $this->user_name = '';
- $this->password = '';
- $this->pop3 = 0;
- $this->imap = 0;
- $this->imap_obj = new MailImap();
- $this->pop3_obj = new MailPop3();
- $this->folder = '';
- }
- Function Connect() {
- if ( $this->imap == true ) {
- $this->imap_obj->CopySettings( $this );
- return $this->imap_obj->Connect();
- }
- if ( $this->pop3 == true ) {
- $this->pop3_obj->CopySettings( $this );
- return $this->pop3_obj->Connect();
- }
- }
- Function Disconnect() {
- if ( $this->imap == true ) {
- $this->imap_obj->CopySettings( $this );
- return $this->Disconnect();
- }
- if ( $this->pop3 == true ) {
- $this->pop3_obj->CopySettings( $this );
- return $this->Disconnect();
- }
- }
- Function Open() {
- return $this->Connect();
- }
- Function Close() {
- return $this->Disconnect();
- }
- Function GetFolder( $folder ) {
- $this->folder = $folder;
- $this->imap_obj->CopySettings( $this );
- $this->pop3_obj->CopySettings( $this );
- $temp_obj = new MailFolder();
- $temp_obj->CopySettings( $this );
- return Array( true, $temp_obj );
- }
- Function ListFolders() {
- $this->imap_obj->CopySettings( $this );
- $this->pop3_obj->CopySettings( $this );
- if ( $this->imap == 1 ) {
- return $this->imap_obj->ListFolders();
- } else {
- /* POP3 Does not do folder support */
- return Array();
- }
- return Array();
- }
- Function CreateFolder( $folder ) {
- $this->imap_obj->CopySettings( $this );
- $this->pop3_obj->CopySettings( $this );
- if ( $this->imap == 1 ) {
- return $this->imap_obj->CreateFolder( $folder );
- } else {
- /* POP3 Does not do folder support */
- return 0;
- }
- return 0;
- }
- Function RemoveFolder( $folder ) {
- $this->imap_obj->CopySettings( $this );
- $this->pop3_obj->CopySettings( $this );
- if ( $this->imap == 1 ) {
- return $this->imap_obj->RemoveFolder( $folder );
- } else {
- /* POP3 Does not do folder support */
- return 0;
- }
- return 0;
- }
- Function SubscribeToFolder( $folder ) {
- $this->imap_obj->CopySettings( $this );
- $this->pop3_obj->CopySettings( $this );
- if ( $this->imap == 1 ) {
- return $this->imap_obj->SubscribeToFolder( $folder );
- } else {
- /* POP3 Does not do folder support */
- return 0;
- }
- return 0;
- }
- Function UnSubscribeFromFolder( $folder ) {
- }
- Function GetBareFolderNameList( $list ) {
- $t_list = Array();
- for( $i = 0; $i < count( $list ); $i++ ) {
- $t_list[] = $this->GetBareFolderName( $list[ $i ] );
- }
- return $t_list;
- }
- Function GetBareFolderName( $folder_name ) {
- if ( ereg( '^{(.*)}(.*)', $folder_name, $regs ) ) {
- return $regs[ 2 ];
- }
- return $folder_name;
- }
- }
- ?>