Mailboxes Chilkat2 PHP Reference Documentation

Mailboxes

Current Version: 11.7.0

Markdown version of this page for AI tools (v 11.7.0) · all AI docs

Chilkat.Mailboxes

Inspect IMAP mailbox names and attributes returned by Chilkat.Imap.

Chilkat.Mailboxes is a read-only result collection populated by Chilkat.Imap.MbxList. Applications inspect the returned mailbox names and attributes but do not directly add, remove, or modify entries. The class provides indexed access to mailbox flags, selectable status, marked status, whether child mailboxes exist, and whether child mailboxes may be created.

Mailbox collection

Receive the read-only list of IMAP mailboxes populated by Chilkat.Imap.MbxList.

Indexed mailbox access

Use the mailbox count and index-based methods to retrieve each mailbox name in the returned collection.

Mailbox flags

Inspect IMAP flags associated with each mailbox, including standard and server-specific attributes.

Selectable status

Determine whether a mailbox can be selected and opened for message access.

Hierarchy information

Check whether a mailbox has child mailboxes or whether children may be created beneath it.

Marked status

Detect whether a mailbox is marked or unmarked according to the attributes returned by the IMAP server.

Common pattern: Call Chilkat.Imap.MbxList to populate a Mailboxes object, loop from 0 to Count - 1, retrieve each mailbox name, and inspect its flags or selectable status. Mailbox names are exposed as normal Unicode text; Chilkat automatically handles modified UTF-7 or IMAP UTF-8 at the protocol level.

Object Creation

use Chilkat2\Mailboxes;

try {
    $mailboxes = new Mailboxes();
    // ... use $mailboxes ...
} catch (\Chilkat2\Exception $e) {
    echo $e->getClass(), '::', $e->getMethod(), " failed\n";
    echo $e->getMessage(), "\n";              // the LastErrorText of the failed call
}
public function __construct(array $properties = [])

Creates the object. The optional array sets properties in order, as if assigned one by one (new Mailboxes(['VerboseLogging' => true, 'RaiseError' => false])); an unknown or read-only name throws Error. The class is defined by the chilkat2 extension (extension=chilkat2 in php.ini): there is no PHP file to include.

There is no close(): PHP frees the object when its last reference goes (unset($mailboxes), $mailboxes = null, or the end of the function or request). Objects returned by methods are independent and freed the same way. The class may be extended (class MyMailboxes extends \Chilkat2\Mailboxes); objects cannot be cloned or serialized.

public bool $RaiseError;

When true (the default), a method that fails throws Chilkat2\Exception. When false, it returns false (or null) instead, and the reason is in LastErrorText. Objects returned by a method inherit the value of the object that returned them.

Errors

Chilkat2\Exception extends RuntimeException: getMessage() is the failed call's full LastErrorText, getClass() its class ('Chilkat2\Mailboxes') and getMethod() the method name. The object remains usable. Methods that look something up and find nothing return null without throwing (each such method says so), methods that answer a question (HasMember, IsUnlocked, ...) return a plain bool, and property reads and writes do not throw for Chilkat reasons.

Misuse always throws, whatever RaiseError is: a wrong argument type is a TypeError (exact types under declare(strict_types=1)), a missing or extra argument an ArgumentCountError, a string containing a NUL byte or an out-of-range integer a ValueError, and an unknown property (properties are case-sensitive) or a write to a read-only one an Error. Named arguments work with the parameter names shown.

Strings are passed and returned as UTF-8; binary data is a PHP string of bytes. Unlocking: call (new \Chilkat2\GlobalSettings())->UnlockBundle('...') once at startup.

Properties

Count
public readonly int $Count;

Returns the number of mailboxes in this collection. An empty collection has a count of 0.

Mailboxes is a read-only result container populated by Imap.MbxList. Applications inspect the returned entries but do not directly add, remove, or modify mailboxes in this object.

top
DebugLogFilePath
public string $DebugLogFilePath;

If set to a file path, this property logs the LastErrorText of each Chilkat method or property call to the specified file. This logging helps identify the context and history of Chilkat calls leading up to any crash or hang, aiding in debugging.

Enabling the VerboseLogging property provides more detailed information. This property is mainly used for debugging rare instances where a Chilkat method call causes a hang or crash, which should generally not happen.

Possible causes of hangs include:

  • A timeout property set to 0, indicating an infinite timeout.
  • A hang occurring within an event callback in the application code.
  • An internal bug in the Chilkat code causing the hang.

More Information and Examples
top
LastErrorHtml
public readonly string $LastErrorHtml;

Provides HTML-formatted information about the last called method or property. If a method call fails or behaves unexpectedly, check this property for details. Note that information is available regardless of the method call's success.

top
LastErrorText
public readonly string $LastErrorText;

Provides plain text information about the last called method or property. If a method call fails or behaves unexpectedly, check this property for details. Note that information is available regardless of the method call's success.

top
LastErrorXml
public readonly string $LastErrorXml;

Provides XML-formatted information about the last called method or property. If a method call fails or behaves unexpectedly, check this property for details. Note that information is available regardless of the method call's success.

top
LastMethodSuccess
public bool $LastMethodSuccess;

Indicates the success or failure of the most recent method call: true means success, false means failure. This property remains unchanged by property setters or getters. This method is present to address challenges in checking for null or Nothing returns in certain programming languages. Note: This property does not apply to methods that return integer values or to boolean-returning methods where the boolean does not indicate success or failure.

top
VerboseLogging
public bool $VerboseLogging;

If set to true, then the contents of LastErrorText (or LastErrorXml, or LastErrorHtml) may contain more verbose information. The default value is false. Verbose logging should only be used for debugging. The potentially large quantity of logged information may adversely affect peformance.

top
Version
public readonly string $Version;

Version of the component/library, such as "10.1.0"

More Information and Examples
top

Methods

GetFlags
public function GetFlags(int $index): ?string

Returns a comma-separated list of flags for the mailbox at the zero-based index specified by $index.

For example:

\HasNoChildren,\Important

To inspect the flags individually, use GetNumFlags and GetNthFlag.

On failure it throws Chilkat2\Exception (or, with RaiseError set to false, returns null). $e->getMessage() (or the object's LastErrorText) explains why, and the object remains usable.

More Information and Examples
top
GetMailboxIndex
public function GetMailboxIndex(string $mbxName): int

Returns the zero-based index of the mailbox whose name matches $mbxName.

Pass $mbxName as a normal Unicode mailbox name. Chilkat automatically handles the protocol-level modified UTF-7 or IMAP UTF-8 representation; the application should not encode the mailbox name manually.

The returned index can be used with methods such as GetName, GetFlags, and IsSelectable.

More Information and Examples
top
GetName
public function GetName(int $index): ?string

Returns the name of the mailbox at the zero-based index specified by $index.

The name is returned as normal Unicode text. Chilkat automatically decodes modified UTF-7 or IMAP UTF-8 mailbox names received from the server and automatically performs the corresponding encoding when the name is passed to an Imap method.

The returned name can therefore be passed directly to methods that select, examine, create, rename, delete, copy to, or otherwise operate on a mailbox. Do not manually encode or decode the mailbox name.

On failure it throws Chilkat2\Exception (or, with RaiseError set to false, returns null). $e->getMessage() (or the object's LastErrorText) explains why, and the object remains usable.

More Information and Examples
top
GetNthFlag
public function GetNthFlag(int $index, int $flagIndex): ?string

Returns one flag from a mailbox in the collection.

  • $index is the zero-based mailbox index.
  • $flagIndex is the zero-based flag index within that mailbox.

Call GetNumFlags to determine the number of flags available for the mailbox.

On failure it throws Chilkat2\Exception (or, with RaiseError set to false, returns null). $e->getMessage() (or the object's LastErrorText) explains why, and the object remains usable.

More Information and Examples
top
GetNumFlags
public function GetNumFlags(int $index): int

Returns the number of flags associated with the mailbox at the zero-based index specified by $index.

Returns -1 if $index is outside the valid mailbox-index range. Use GetNthFlag to retrieve the individual flags.

More Information and Examples
top
HasFlag
public function HasFlag(int $index, string $flagName): bool

Returns true if the mailbox at the zero-based index specified by $index contains the flag named by $flagName.

Flag-name comparison is case-insensitive. Include the leading backslash when checking an IMAP system flag or mailbox attribute, for example \Marked, \Noselect, or \HasChildren.

Never throws: false is an answer, not a failure.

top
HasInferiors
public function HasInferiors(int $index): bool

Returns true if the mailbox at the zero-based index specified by $index either has child mailboxes or permits child mailboxes to be created beneath it.

Important distinction: \HasNoChildren means that no child mailboxes currently exist. It does not mean that children cannot be created. The IMAP \Noinferiors attribute means that child mailboxes cannot be created.

Never throws: false is an answer, not a failure.

More Information and Examples
top
IsMarked
public function IsMarked(int $index): bool

Returns true if the mailbox at the zero-based index specified by $index has the IMAP \Marked attribute.

\Marked is a server-provided hint that the mailbox may contain messages added since it was last selected. It is advisory information returned by the mailbox-listing operation.

Never throws: false is an answer, not a failure.

More Information and Examples
top
IsSelectable
public function IsSelectable(int $index): bool

Returns true if the mailbox at the zero-based index specified by $index can be selected or examined for message access.

A mailbox having the IMAP \Noselect attribute is not selectable, even though it may appear in the mailbox hierarchy and may contain selectable child mailboxes.

Never throws: false is an answer, not a failure.

More Information and Examples
top