ezcMailImapTransport::fetchByMessageNr PHP 메소드

fetchByMessageNr() 공개 메소드

This method supports unique IDs instead of message numbers. See {@link ezcMailImapTransportOptions} for how to enable unique IDs referencing. If $deleteFromServer is set to true the mail will be marked for deletion after retrieval. If not it will be left intact. Note: for IMAP the first message is 1 (so for $number = 0 an exception will be thrown). Before calling this method, a connection to the IMAP server must be established and a user must be authenticated successfully, and a mailbox must be selected. Example: $imap = new ezcMailImapTransport( 'imap.example.com' ); $imap->authenticate( 'username', 'password' ); $imap->selectMailbox( 'Inbox' ); $set = $imap->fetchByMessageNr( 1 ); $set can be parsed with ezcMailParser
public fetchByMessageNr ( integer $number, boolean $deleteFromServer = false ) : ezcMailImapSet
$number integer
$deleteFromServer boolean
리턴 ezcMailImapSet
    public function fetchByMessageNr($number, $deleteFromServer = false)
    {
        if ($this->options->uidReferencing) {
            $messages = array_flip($this->listUniqueIdentifiers());
        } else {
            $messages = $this->listMessages();
        }
        if (!isset($messages[$number])) {
            throw new ezcMailNoSuchMessageException($number);
        }
        return new ezcMailImapSet($this->connection, array(0 => $number), $deleteFromServer, array('uidReferencing' => $this->options->uidReferencing));
    }

Usage Example

예제 #1
0
 public function testImapMessageSource()
 {
     $transport = new ezcMailImapTransport("mta1.ez.no");
     $transport->authenticate("*****@*****.**", "ezcomponents");
     $transport->selectMailbox("Inbox");
     $parser = new ezcMailParser();
     $set = new ezcMailStorageSet($transport->fetchByMessageNr(1), $this->tempDir);
     $mail = $parser->parseMail($set);
     $files = $set->getSourceFiles();
     $source = file_get_contents($files[0]);
     $this->assertEquals(self::$sizes[0], strlen($source));
 }
All Usage Examples Of ezcMailImapTransport::fetchByMessageNr