Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- class xMailClient {
- /*
- host connect to server
- example: mail.example.com
- */
- public $server;
- public $errText;
- /*
- port connect to server
- example: 110, 993, 995
- */
- public $port = 110;
- /*
- type connect to server
- example: pop3, pop3/ssl, pop3/ssl/novalidate-cert
- */
- public $type = "pop3";
- public $count;
- public $msg;
- /*
- user login connect to server
- */
- private $user;
- /*
- user password connect to server
- */
- private $pass;
- private $box;
- public function __construct() {
- $this->errText='';
- if (!extension_loaded("imap"))
- {
- if (strtoupper(substr(PHP_OS, 0, 3)) == 'WIN')
- {
- dl('php_imap.dll');
- }
- else
- {
- dl('php_imap.so');
- }
- if (!extension_loaded("imap"))
- {
- $this->error("Could not load required extension... Please install extansion.");
- }
- }
- }
- public function user( $user, $pass ) {
- $this->user = $user;
- $this->pass = $pass;
- }
- public function server( $server, $port, $type ) {
- $this->server = $server;
- $this->port = $port;
- $this->type = $type;
- }
- public function open() {
- $this->box = @imap_open("{".$this->server.":".$this->port."/".$this->type."}INBOX", $this->user, $this->pass);
- if($this->box)
- {
- return true;
- }
- if (imap_last_error())
- {
- $this->error(imap_last_error());
- return false;
- }
- else
- {
- $this->error("Couldn't open stream ".$this->server.":".$this->port."...");
- return false;
- }
- return true;
- }
- public function select($id) {
- $this->msg = $id;
- return imap_headerinfo($this->box, $id);
- }
- public function count() {
- $this->count = imap_num_msg($this->box);
- return $this->count;
- }
- public function msg_body() {
- return imap_body($this->box,$this->msg);
- }
- public function delete($id) {
- imap_delete($this->box, $id);
- imap_expunge($this->box);
- }
- public function error($error) {
- $this->errText=$error;
- return true;
- }
- public function close() {
- return imap_close($this->box);
- }
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement