selectMailbox() public method

Before calling this method, a connection to the IMAP server must be established and a user must be authenticated successfully. Inbox is a special mailbox and can be specified with any case. This method should be called after authentication, and before fetching any messages. Example of selecting a mailbox: $imap = new ezcMailImapTransport( 'imap.example.com' ); $imap->authenticate( 'username', 'password' ); $imap->selectMailbox( 'Reports 2006' );
public selectMailbox ( string $mailbox, boolean $readOnly = false )
$mailbox string
$readOnly boolean
コード例 #1
0
 public function testUidDelete()
 {
     $imap = new ezcMailImapTransport(self::$server, self::$port, array('uidReferencing' => true));
     $imap->authenticate(self::$user, self::$password);
     $imap->createMailbox("Guybrush");
     $imap->selectMailbox('inbox');
     $imap->copyMessages(self::$ids[0], "Guybrush");
     $imap->selectMailbox("Guybrush");
     $imap->delete(1);
     $imap->selectMailbox('inbox');
     $imap->deleteMailbox("Guybrush");
 }
コード例 #2
0
<?php

require_once 'tutorial_autoload.php';
// Create a new IMAP transport object by specifying the server name
$imap = new ezcMailImapTransport("imap.example.com");
// Authenticate to the IMAP server
$imap->authenticate("user", "password");
// Select the Inbox mailbox
$imap->selectMailbox('Inbox');
// List the capabilities of the IMAP server
$capabilities = $imap->capability();
// List existing mailboxes
$mailboxes = $imap->listMailboxes("", "*");
// Fetch the hierarchy delimiter character (usually "/")
$delimiter = $imap->getHierarchyDelimiter();
// Create a new mailbox
$imap->createMailbox("Reports 2006");
// Delete a mailbox
$imap->deleteMailbox("Reports 2005");
// Rename a mailbox
$imap->renameMailbox("Reports 2006", "Reports");
// Copy messages from the selected mailbox (here: Inbox) to another mailbox
$imap->copyMessages("1,2,4", "Reports");
// Set a flag to messages
// See the function description for a list of supported flags
$imap->setFlag("1,2,4", "DELETED");
// Clears a flag from messages
// See the function description for a list of supported flags
$imap->clearFlag("1,2,4", "SEEN");
// Append a message to a mailbox. $mail must contain the mail as text
// Use this with a "Sent" or "Drafts" mailbox
コード例 #3
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]));
     }
 }
コード例 #4
0
ファイル: ClientTest.php プロジェクト: tvpsoft/laravel-kinvey
 /**
  * Get the password reset URL.
  *
  * @return string
  */
 public static function getPasswordResetURL()
 {
     $options = new \ezcMailImapTransportOptions();
     $options->ssl = true;
     $imap = new \ezcMailImapTransport('imap.gmail.com', null, $options);
     $imap->authenticate('*****@*****.**', Config::get('kinvey::testMail'));
     $imap->selectMailbox('Inbox');
     $set = $imap->searchMailbox('FROM "*****@*****.**"');
     $parser = new \ezcMailParser();
     $mail = $parser->parseMail($set);
     preg_match("#https.*#", $mail[0]->generateBody(), $matches);
     $url = html_entity_decode($matches[0]);
     $url = mb_substr($url, 0, -1);
     foreach ($set->getMessageNumbers() as $msgNum) {
         $imap->delete($msgNum);
     }
     $imap->expunge();
     return $url;
 }
コード例 #5
0
ファイル: mail.php プロジェクト: notion/zeta-mail
// Required method to be able to use the eZ Components
function __autoload($className)
{
    ezcBase::autoload($className);
}
// Start counting how much the execution time will be
$start = microtime(true);
// Read configuration file app.ini with the Configuration component
$iniFile = 'app';
$config = ezcConfigurationManager::getInstance();
$config->init('ezcConfigurationIniReader', dirname(__FILE__));
$options = array('templatePath' => dirname(__FILE__) . $config->getSetting($iniFile, 'TemplateOptions', 'TemplatePath'), 'compilePath' => dirname(__FILE__) . $config->getSetting($iniFile, 'TemplateOptions', 'CompilePath'), 'server' => $config->getSetting($iniFile, 'MailOptions', 'Server'), 'user' => $config->getSetting($iniFile, 'MailOptions', 'User'), 'password' => $config->getSetting($iniFile, 'MailOptions', 'Password'), 'mailbox' => isset($_GET['mailbox']) ? $_GET['mailbox'] : $config->getSetting($iniFile, 'MailOptions', 'Mailbox'), 'pageSize' => $config->getSetting($iniFile, 'MailOptions', 'PageSize'), 'currentPage' => isset($_GET['page']) ? $_GET['page'] : null);
// Create a mail IMAP transport object
$transport = new ezcMailImapTransport($options["server"]);
$transport->authenticate($options["user"], $options["password"]);
$transport->selectMailbox($options["mailbox"]);
// Get the mailboxes names from the server
$mailboxes = $transport->listMailboxes();
sort($mailboxes);
// Get the UIDs of the messages in the selected mailbox
// and the sizes of the messages
$mailIDs = $transport->listUniqueIdentifiers();
$messages = $transport->listMessages();
// Calculate how many pages of mails there will be based on pageSize
$numberOfPages = (int) floor(count($messages) / $options["pageSize"] + 1);
// See if currentPage fits in the range 1..numberOfPages
if ($options["currentPage"] <= 0 || $options["currentPage"] > $numberOfPages || count($messages) % $options["pageSize"] === 0 && $options["currentPage"] >= $numberOfPages) {
    $options["currentPage"] = 1;
}
// Slice the array to the range defined by currentPage
$sizes = array_slice(array_values($messages), ($options["currentPage"] - 1) * $options["pageSize"], $options["pageSize"]);
コード例 #6
0
 /**
  * Test for issue #14360: problems with $imap->top() command in gmail.
  */
 public function testTopGmailHeadersOnly()
 {
     $options = new ezcMailImapTransportOptions();
     $options->ssl = true;
     $imap = new ezcMailImapTransport('imap.gmail.com', '993', $options);
     // please don't use this account :)
     $imap->authenticate('ezcomponents' . '@' . 'gmail.com', 'wee12345');
     $imap->selectMailbox('inbox');
     $text = $imap->top(1, 1);
     $this->assertEquals(382, strlen($text));
 }