ImapConnection
class ImapConnection implements ConnectionInterface (View source)
Properties
| protected int | $sequence | Sequence number used to generate unique command tags. |
|
| protected Result|null | $result | The result instance. |
|
| protected ImapParser|null | $parser | The parser instance. |
Methods
Create a new connection with a fake stream.
Tear down the connection.
Open a new connection.
Get the default socket options for the given transport.
Close the current connection.
Determine if the current session is connected.
Send a "LOGIN" command.
Send a "LOGOUT" command.
Send an "AUTHENTICATE" command.
Send a "STARTTLS" command.
Send a "SELECT" command.
Send a "EXAMINE" command.
Examine and select have the same response.
Send a "STATUS" command.
Send a "CREATE" command.
Send a "DELETE" command.
Send a "RENAME" command.
Send a "SUBSCRIBE" command.
Send a "UNSUBSCRIBE" command.
Send a "GETQUOTA" command.
Send a "GETQUOTAROOT" command.
Send a "LIST" command.
Send a "APPEND" command.
Send a "UID COPY" command.
Send a "UID MOVE" command.
Send a "STORE" command.
Send a "FETCH UID" command.
Send a "FETCH BODY[TEXT]" command.
Send a "FETCH BODY[HEADER]" command.
Fetch the BODYSTRUCTURE for the given message(s).
Fetch a specific part of the message BODY, such as BODY[1], BODY[1.2], etc.
Send a "FETCH FLAGS" command.
Send a "RFC822.SIZE" command.
Send a "SEARCH" command.
Send a "CAPABILITY" command.
Send a "FETCH" command.
Send a "EXPUNGE" command.
Send a "NOOP" command.
Send a "DONE" command.
Send an IMAP command.
Write data to the connected stream.
Fetch one or more items for one or more messages.
Assert the next response is a successful tagged response.
Assert the next response matches the given filter and assertion.
Returns the next response matching the given filter.
Details
__construct(StreamInterface $stream, LoggerInterface|null $logger = null)
Constructor.
static ImapConnection
fake(array $responses = [])
Create a new connection with a fake stream.
__destruct()
Tear down the connection.
void
connect(string $host, int|null $port = null, array $options = [])
Open a new connection.
protected array
getDefaultSocketOptions(string $transport, array $proxy = [], bool $validateCert = true)
Get the default socket options for the given transport.
void
disconnect()
Close the current connection.
bool
connected()
Determine if the current session is connected.
TaggedResponse
login(string $user, string $password)
Send a "LOGIN" command.
Login to a new session.
void
logout()
Send a "LOGOUT" command.
Logout of the current server session.
TaggedResponse
authenticate(string $user, string $token)
Send an "AUTHENTICATE" command.
Authenticate the current session.
void
startTls()
Send a "STARTTLS" command.
Upgrade the current plaintext connection to a secure TLS-encrypted connection.
ResponseCollection
select(string $folder = 'INBOX')
Send a "SELECT" command.
Select the specified folder.
ResponseCollection
examine(string $folder = 'INBOX')
Send a "EXAMINE" command.
Examine a given folder.
protected ResponseCollection
examineOrSelect(string $command = 'EXAMINE', string $folder = 'INBOX')
Examine and select have the same response.
UntaggedResponse
status(string $folder = 'INBOX', array $arguments = ['MESSAGES', 'UNSEEN', 'RECENT', 'UIDNEXT', 'UIDVALIDITY'])
Send a "STATUS" command.
Get the status of a given folder.
ResponseCollection
create(string $folder)
Send a "CREATE" command.
Create a new folder.
TaggedResponse
delete(string $folder)
Send a "DELETE" command.
Delete a folder.
TaggedResponse
rename(string $oldPath, string $newPath)
Send a "RENAME" command.
Rename an existing folder.
TaggedResponse
subscribe(string $folder)
Send a "SUBSCRIBE" command.
Subscribe to a folder.
TaggedResponse
unsubscribe(string $folder)
Send a "UNSUBSCRIBE" command.
Unsubscribe from a folder.
UntaggedResponse
quota(string $root)
Send a "GETQUOTA" command.
Retrieve quota information about a specific quota root.
ResponseCollection
quotaRoot(string $mailbox)
Send a "GETQUOTAROOT" command.
Retrieve quota root information about a mailbox.
ResponseCollection
list(string $reference = '', string $folder = '*')
Send a "LIST" command.
Get a list of available folders.
TaggedResponse
append(string $folder, string $message, array|null $flags = null)
Send a "APPEND" command.
Append a new message to given folder.
TaggedResponse
copy(string $folder, array|int $from, int|null $to = null)
Send a "UID COPY" command.
Copy message set from current folder to other folder.
TaggedResponse
move(string $folder, array|int $from, int|null $to = null)
Send a "UID MOVE" command.
Move a message set from current folder to another folder.
ResponseCollection
store(array|string $flags, array|int $from, int|null $to = null, string|null $mode = null, bool $silent = true, string|null $item = null)
Send a "STORE" command.
Set message flags.
ResponseCollection
uid(int|array $ids, ImapFetchIdentifier $identifier)
Send a "FETCH UID" command.
Fetch message UIDs using the given message numbers.
ResponseCollection
bodyText(int|array $ids, bool $peek = true)
Send a "FETCH BODY[TEXT]" command.
Fetch message text contents.
ResponseCollection
bodyHeader(int|array $ids, bool $peek = true)
Send a "FETCH BODY[HEADER]" command.
Fetch message headers.
ResponseCollection
bodyStructure(int|array $ids)
Fetch the BODYSTRUCTURE for the given message(s).
ResponseCollection
bodyPart(string $partIndex, int|array $ids, bool $peek = false)
Fetch a specific part of the message BODY, such as BODY[1], BODY[1.2], etc.
ResponseCollection
flags(int|array $ids)
Send a "FETCH FLAGS" command.
Fetch a message flags.
ResponseCollection
size(int|array $ids)
Send a "RFC822.SIZE" command.
Fetch message sizes for one or more messages.
UntaggedResponse
search(array $params)
Send a "SEARCH" command.
Execute a search request.
UntaggedResponse
capability()
Send a "CAPABILITY" command.
Get the mailbox's available capabilities.
UntaggedResponse
id(array|null $ids = null)
Send a "FETCH" command.
Exchange identification information.
ResponseCollection
expunge()
Send a "EXPUNGE" command.
Apply session saved changes to the server.
TaggedResponse
noop()
Send a "NOOP" command.
Generator
idle(int $timeout)
Send an "IDLE" command.
void
done()
Send a "DONE" command.
void
send(string $name, array $tokens = [], string|null $tag = null)
Send an IMAP command.
protected void
write(string $data)
Write data to the connected stream.
ResponseCollection
fetch(array|string $items, array|int $from, mixed $to = null, ImapFetchIdentifier $identifier = ImapFetchIdentifier::Uid)
Fetch one or more items for one or more messages.
protected void
setResult(Result $result)
Set the current result instance.
protected void
setParser(ImapParser $parser)
Set the current parser instance.
protected ImapParser
newParser(StreamInterface $stream)
Create a new parser instance.
protected ImapTokenizer
newTokenizer(StreamInterface $stream)
Create a new tokenizer instance.
protected TaggedResponse
assertTaggedResponse(string $tag, callable|null $exception = null)
Assert the next response is a successful tagged response.
protected Response
assertNextResponse(callable $filter, callable $assertion, callable $exception)
Assert the next response matches the given filter and assertion.
protected Response|null
nextResponse(callable $filter)
Returns the next response matching the given filter.