View difference between Paste ID: uc9Cwjgj and FAQjqfCr
SHOW: | | - or go back to the newest paste.
1
<?php
2
3
define('SERVER', "{imap.gmail.com:993/imap/ssl}INBOX");
4
5
class gmail {
6
	var $oMailBox;
7
	var $sUser;
8
	var $sPassword;
9
	
10
	
11
	function gmail($user, $password) {
12
		$this->sUser = $user;
13
		$this->sPassword = $password;
14
		
15
		$this->oMailBox = imap_open (SERVER, $this->sUser, $this->sPassword)
16
			or die("can't connect: " . imap_last_error());
17
	}
18
	
19
	function countUnread() {
20
		if ($oMailBox !== FALSE) {
21
			$oStatus = imap_status($this->oMailBox, SERVER, SA_UNSEEN);
22
			return $oStatus->unseen;
23
		}
24
	}
25
	
26
	function disconnect() {
27
		return imap_close($this->oMailBox);
28
	}
29
}
30
31
32
?>