For more information about the hierarchy delimiter, consult the IMAP RFCs
{@link http://www.faqs.org/rfcs/rfc1730.html} or
{@link http://www.faqs.org/rfcs/rfc2060.html}, section 6.3.8.
Before calling this method, a connection to the IMAP server must be
established and a user must be authenticated successfully.
Example of returning the hierarchy delimiter:
$imap = new ezcMailImapTransport( 'imap.example.com' );
$imap->authenticate( 'username', 'password' );
$delimiter = $imap->getDelimiter();
After running the above code, $delimiter should be something like "/". public getHierarchyDelimiter ( ) : string | ||
return | string |
<?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
public function testGetHierarchyDelimiterFail() { $imap = new ezcMailImapTransport(self::$server, self::$port); try { $imap->getHierarchyDelimiter(); $this->fail('Expected exception was not thrown.'); } catch (ezcMailTransportException $e) { $this->assertEquals("An error occured while sending or receiving mail. Can't call getDelimiter() when not successfully logged in.", $e->getMessage()); } }