fetchAll() public method

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. The set returned can be parsed with {@link ezcMailParser}. 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->fetchAll(); parse $set with ezcMailParser $parser = new ezcMailParser(); $mails = $parser->parseMail( $set ); foreach ( $mails as $mail ) { process $mail which is an ezcMail object }
public fetchAll ( boolean $deleteFromServer = false ) : ezcMailParserSet
$deleteFromServer boolean
return ezcMailParserSet
コード例 #1
0
 public function testUidCommandsFetchAll()
 {
     $imap = new ezcMailImapTransport(self::$server, self::$port, array('uidReferencing' => true));
     $imap->authenticate(self::$user, self::$password);
     $imap->selectMailbox('inbox');
     $set = $imap->fetchAll();
     $this->assertEquals(array(self::$ids[0], self::$ids[1], self::$ids[2], self::$ids[3]), $set->getMessageNumbers());
     $parser = new ezcMailParser();
     $mails = $parser->parseMail($set);
     $this->assertEquals(4, count($mails));
 }
コード例 #2
0
 /**
  * Test modified for issue #14776: ezcMailStorageSet generates bad file names.
  */
 public function testGetSourceFileNames()
 {
     $transport = new ezcMailImapTransport("mta1.ez.no");
     $transport->authenticate("*****@*****.**", "ezcomponents");
     $transport->selectMailbox("Inbox");
     $parser = new ezcMailParser();
     $set = new ezcMailStorageSet($transport->fetchAll(), $this->tempDir);
     $mail = $parser->parseMail($set);
     $files = $set->getSourceFiles();
     $expected = array(getmypid() . '-' . time() . '-' . 1, getmypid() . '-' . time() . '-' . 2, getmypid() . '-' . time() . '-' . 3, getmypid() . '-' . time() . '-' . 4);
     for ($i = 0; $i < count($files); $i++) {
         $this->assertEquals($expected[$i], basename($files[$i]));
     }
 }
コード例 #3
0
 public function testTagInHeadersAndBody()
 {
     $imap = new ezcMailImapTransport(self::$server, self::$port);
     $imap->authenticate(self::$user, self::$password);
     $imap->createMailbox("Guybrush");
     $mail = new ezcMail();
     $mail->from = new ezcMailAddress('*****@*****.**', 'From');
     $mail->addTo(new ezcMailAddress('*****@*****.**', 'To'));
     $mail->subject = "A0000 A0001 A0002 A0003 A0004 A0005 A0006 A0007";
     $mail->body = new ezcMailText("A0000\nA0001\nA0002\nA0003\nA0004\nA0005\nA0006\nA0007");
     $data = $mail->generate();
     $imap->append("Guybrush", $data);
     $imap->append("Guybrush", $data, array('Answered'));
     $imap->selectMailbox("Guybrush");
     $set = $imap->fetchAll();
     $parser = new ezcMailParser();
     $mail = $parser->parseMail($set);
     $mail = $mail[0];
     $imap->selectMailbox("Inbox");
     $imap->deleteMailbox("Guybrush");
     $this->assertEquals('A0000 A0001 A0002 A0003 A0004 A0005 A0006 A0007', $mail->subject);
 }
コード例 #4
0
ファイル: receive_mail.php プロジェクト: Qafoo/blog-examples
<?php

require_once '/home/dotxp/dev/PHP/zetacomponents/trunk/Base/src/ezc_bootstrap.php';
require_once 'blog_entry.php';
require_once 'blog_entry_creator.php';
$imapOptions = new ezcMailImapTransportOptions();
$imapOptions->ssl = true;
$imap = new ezcMailImapTransport('example.com', 993, $imapOptions);
$imap->authenticate('*****@*****.**', 'foo23bar');
$imap->selectMailbox('Inbox');
$messageSet = $imap->fetchAll();
$parser = new ezcMailParser();
$mails = $parser->parseMail($messageSet);
$blogEntryCreator = new qaBlogEntryCreator();
foreach ($mails as $mail) {
    $entry = $blogEntryCreator->createEntry($mail);
    $entry->save();
}
コード例 #5
0
ファイル: tutorial_imap.php プロジェクト: notion/zeta-mail
$imap->selectMailbox('Inbox');
// Get the number of messages on the server, combined size, number of recent
// messages and number of unseen messages
// in the variables $num, $size, $recent, $unseen
$imap->status($num, $size, $recent, $unseen);
// Get the list of message numbers on the server and their sizes
// the returned array is something like: array( 1 => 1500, 2 => 45200 )
// where the key is a message number and the value is the message size
$messages = $imap->listMessages();
// Get the list of message unique ids on the server and their sizes
// the returned array is something like: array( 1 => '15', 2 => '16' )
// where the key is an message number and the value is the message unique id
$messages = $imap->listUniqueIdentifiers();
// Usually you will call one of these fetch functions:
// Fetch all messages on the server
$set = $imap->fetchAll();
// Fetch one message from the server (here: get the message no. 2)
$set = $imap->fetchByMessageNr(2);
// Fetch a range of messages from the server (here: get 4 messages starting from message no. 2)
$set = $imap->fetchFromOffset(2, 4);
// Fetch messages which have a certain flag
// See the function description for a list of supported flags
$set = $imap->fetchByFlag("DELETED");
// Fetch a range of messages sorted by Date
// Use this to page through a mailbox
// See the function description for a list of criterias and for how to sort ascending or descending
$set = $imap->sortFromOffset(1, 10, "Date");
// Sort the specified messages by Date
// See the function description for a list of criterias and for how to sort ascending or descending
$set = $imap->sortMessages("1,2,3,4,5", "Date");
// Fetch messages which match the specified criteria.
コード例 #6
0
ファイル: send_digest.php プロジェクト: Qafoo/blog-examples
<?php

require_once '/home/dotxp/dev/PHP/zetacomponents/trunk/Base/src/ezc_bootstrap.php';
$imapOptions = new ezcMailImapTransportOptions();
$imapOptions->ssl = true;
$imap = new ezcMailImapTransport('example.com', 993, $imapOptions);
$imap->authenticate('*****@*****.**', 'foo23bar');
$imap->selectMailbox('Inbox');
$mailSet = $imap->fetchAll();
$parser = new ezcMailParser();
$retMails = $parser->parseMail($mailSet);
$mail = new ezcMail();
$mail->from = new ezcMailAddress('*****@*****.**');
$mail->addTo(new ezcMailAddress('*****@*****.**', 'Any Body'));
$mail->subject = 'Daily digest';
$digest = new ezcMailMultipartDigest();
foreach ($retMails as $retMail) {
    $digest->appendPart(new ezcMailRfc822Digest($retMail));
}
$mail->body = $digest;
$transport = new ezcMailMtaTransport();
$transport->send($mail);