Location: PHPKode > scripts > MicroPHP Mail Checker > microphp-mail-checker/mailchk.class.php
<?php
/******************* mailchk.class.php *******************
*
* Author   : Rashad Aliyev
* Created  : 22/05/2006
* Info     : Class for check mail
* Contacts : hide@address.com
* Mobile   : (+994 50) 648 2737
*
******************** mailchk.class.php ******************/

class Mailchk
{
	var $mailbox = "{your.imap.host:143}";
	var $username = "username";
	var $password = "password";
	var $mbox;
	
	function openMail()
	{
		
		$this->mbox = imap_open ( $this->mailbox, $this->username, $this->password );
		
	}
	
	function numMsg()
	{
		
		return imap_num_msg ( $this->mbox );
		
	}
	
	function listMails()
	{
		
		$mailArr = array();
		
		for ($i=1; $i<=$this->numMsg(); $i++)
		{
			
			$headerArr = $this->mailHeader( $i );
			
			$mailArr[] = 
				array(
					'sender' => $headerArr->sender[0]->mailbox . "@" . $headerArr->sender[0]->host,
					'to' => $headerArr->to[0]->mailbox . "@" . $headerArr->to[0]->host,
					'date' => $headerArr->date,
					'size' => $headerArr->Size,
					'subject' => $headerArr->subject,
					'body' => $this->mailBody( $i )
				);
				
		}
		
		return $mailArr;
		
	}
	
	function mailBody( $num )
	{
		
		return imap_body ( $this->mbox, $num );
		
	}
	
	function mailHeader( $num )
	{
		
		return imap_headerinfo ( $this->mbox, $num );
		
	}
	
	function closeMail()
	{
		
		imap_close($this->mbox);
		
	}
}
/******************* header.php *******************
*
* Copyright : (C) 2004 - 2006. All Rights Reserved
*
******************** header.php ******************/
?>
Return current item: MicroPHP Mail Checker