Blame view

common/components/mail/ImapMailReader.php 1.25 KB
7f6a9301   Mihail   add mails classes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
  <?php
  /**
   * Created by PhpStorm.
   * User: Tsurkanov
   * Date: 02.11.2015
   * Time: 16:56
   */
  
  namespace common\components\mail;
  
  
  class ImapMailReader extends  MailReader {
  
      function __construct( $hostname, $username, $password )
      {
          parent::__construct($hostname, $username, $password);
          $this->connection = imap_open($hostname, $username, $password);
  
          if ($this->connection === false)
57e5a4b9   Mihail   add classes to wo...
20
              throw new \Exception('Cannot connect to mail: ' . imap_last_error());
7f6a9301   Mihail   add mails classes
21
22
23
24
25
26
27
28
  
      }
  
      public function getEmails( $flag )
      {
         return imap_search( $this->connection, $flag );
      }
  
57e5a4b9   Mihail   add classes to wo...
29
30
31
32
33
      public function getEmailBody( $email_number, $section )
      {
         return imap_fetchbody($this->connection, $email_number, $section );
      }
  
7f6a9301   Mihail   add mails classes
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
      /**
       * @return mixed
       */
      public function getListMailboxes()
      {
         return imap_list($this->connection, $this->hostname, "*");
      }
  
      public function getCurrentEmailStructure( $email_number )
      {
          return imap_fetchstructure($this->connection, $email_number);
      }
  
      public function reOpen( $hostname )
      {
          imap_reopen( $this->connection, $hostname );
      }
  
      function __destruct()
      {
          /* close the connection */
          imap_close( $this->connection );
      }
  
  
  }