Advertisement
Guest User

Untitled

a guest
Jun 23rd, 2017
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.53 KB | None | 0 0
  1. <?php
  2. class xMailClient {
  3. /*
  4. host connect to server
  5. example: mail.example.com
  6. */
  7. public $server;
  8.  
  9. public $errText;
  10.  
  11. /*
  12. port connect to server
  13. example: 110, 993, 995
  14. */
  15. public $port = 110;
  16.  
  17. /*
  18. type connect to server
  19. example: pop3, pop3/ssl, pop3/ssl/novalidate-cert
  20. */
  21. public $type = "pop3";
  22.  
  23. public $count;
  24.  
  25. public $msg;
  26.  
  27. /*
  28. user login connect to server
  29. */
  30. private $user;
  31.  
  32. /*
  33. user password connect to server
  34. */
  35. private $pass;
  36.  
  37. private $box;
  38.  
  39. public function __construct() {
  40. $this->errText='';
  41. if (!extension_loaded("imap"))
  42. {
  43. if (strtoupper(substr(PHP_OS, 0, 3)) == 'WIN')
  44. {
  45. dl('php_imap.dll');
  46. }
  47. else
  48. {
  49. dl('php_imap.so');
  50. }
  51. if (!extension_loaded("imap"))
  52. {
  53. $this->error("Could not load required extension... Please install extansion.");
  54. }
  55. }
  56.  
  57. }
  58.  
  59. public function user( $user, $pass ) {
  60. $this->user = $user;
  61. $this->pass = $pass;
  62. }
  63.  
  64. public function server( $server, $port, $type ) {
  65. $this->server = $server;
  66. $this->port = $port;
  67. $this->type = $type;
  68. }
  69.  
  70. public function open() {
  71. $this->box = @imap_open("{".$this->server.":".$this->port."/".$this->type."}INBOX", $this->user, $this->pass);
  72.  
  73. if($this->box)
  74. {
  75. return true;
  76. }
  77. if (imap_last_error())
  78. {
  79. $this->error(imap_last_error());
  80. return false;
  81. }
  82. else
  83. {
  84. $this->error("Couldn't open stream ".$this->server.":".$this->port."...");
  85. return false;
  86. }
  87.  
  88. return true;
  89. }
  90.  
  91. public function select($id) {
  92. $this->msg = $id;
  93. return imap_headerinfo($this->box, $id);
  94. }
  95. public function count() {
  96. $this->count = imap_num_msg($this->box);
  97. return $this->count;
  98. }
  99.  
  100. public function msg_body() {
  101. return imap_body($this->box,$this->msg);
  102. }
  103.  
  104. public function delete($id) {
  105. imap_delete($this->box, $id);
  106. imap_expunge($this->box);
  107. }
  108.  
  109. public function error($error) {
  110. $this->errText=$error;
  111. return true;
  112. }
  113.  
  114. public function close() {
  115. return imap_close($this->box);
  116. }
  117.  
  118. }
  119. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement