Imap
extends AbstractMailClient
in package
Mail client IMAP class
NOTE: Many enterprise mail applications have discontinued support of IMAP and it is no longer allowed.
Tags
Table of Contents
Properties
- $connection : mixed
- Mailbox connection resource
- $connectionString : string|null
- Mailbox connection string
- $folder : string
- Current folder
- $host : string|null
- Mail client host
- $password : string
- Password
- $port : int|string|null
- Mail client port
- $service : string|null
- Mail client service (pop, imap, nntp, etc.)
- $username : string
- Username
Methods
- __construct() : mixed
- Constructor
- clearMessageFlags() : Imap
- Mark a message or messages as unread
- close() : void
- Close the mailbox connection resource
- connect() : Imap
- Connect to an IMAP mailbox
- connection() : mixed
- Get mailbox connection
- copyMessage() : Imap
- Copy messages to another mailbox
- createMailbox() : Imap
- Create mailbox
- decodeText() : string
- Decode text
- deleteMailbox() : Imap
- Delete mailbox
- deleteMessage() : Imap
- Delete message
- getConnectionString() : string|null
- Get mailbox connection string
- getFolder() : string
- Get folder
- getHost() : string|null
- Get mail client host
- getInfo() : stdClass
- Get mailbox info
- getMessageAttachments() : array<string|int, mixed>
- Get message parts by message ID
- getMessageBody() : string
- Get message body by message ID
- getMessageBoundary() : string|null
- Get message boundary by message ID
- getMessageHeaderInfoById() : array<string|int, mixed>
- Get raw message headers by message ID
- getMessageHeaders() : array<string|int, mixed>
- Get message headers from a mailbox
- getMessageHeadersBy() : array<string|int, mixed>
- Get message headers from a mailbox
- getMessageHeadersById() : array<string|int, mixed>
- Get message headers by message ID
- getMessageIds() : array<string|int, mixed>
- Get message IDs from a mailbox
- getMessageIdsBy() : array<string|int, mixed>
- Get message IDs from a mailbox by a sort criteria
- getMessageNumber() : int
- Get message number from UID
- getMessageParts() : array<string|int, mixed>
- Get message parts by message ID
- getMessageRawHeadersById() : array<string|int, mixed>
- Get raw message headers by message ID
- getMessageStructure() : stdClass
- Get message structure by message ID
- getNumberOfMessages() : int
- Get total number of messages
- getNumberOfReadMessages() : int
- Get total number of read messages
- getNumberOfUnreadMessages() : int
- Get total number of unread messages
- getOverview() : array<string|int, mixed>
- Get message overviews
- getPassword() : string
- Get password
- getPort() : int|string|null
- Get mail client port
- getService() : string|null
- Get mail client service
- getStatus() : stdClass
- Get mailbox status
- getUsername() : string
- Get username
- hasMessageAttachments() : bool
- Get message parts by message ID
- isOpen() : bool
- Determine if the mailbox connection has been opened
- listMailboxes() : array<string|int, mixed>
- List mailboxes
- markAsRead() : Imap
- Mark a message or messages as read
- markAsUnread() : Imap
- Mark a message or messages as unread
- moveMessage() : Imap
- Move messages to another mailbox
- open() : Imap
- Open mailbox connection
- renameMailbox() : Imap
- Rename mailbox
- setFolder() : AbstractMailClient
- Set folder
- setHost() : AbstractMailClient
- Set mail client host
- setMessageFlags() : Imap
- Mark a message or messages as read
- setPassword() : AbstractMailClient
- Set password
- setPort() : AbstractMailClient
- Set mail client port
- setService() : AbstractMailClient
- Set mail client service
- setUsername() : AbstractMailClient
- Set username
Properties
$connection
Mailbox connection resource
protected
mixed
$connection
= null
$connectionString
Mailbox connection string
protected
string|null
$connectionString
= null
$folder
Current folder
protected
string
$folder
= ''
$host
Mail client host
protected
string|null
$host
= null
$password
Password
protected
string
$password
= ''
$port
Mail client port
protected
int|string|null
$port
= null
$service
Mail client service (pop, imap, nntp, etc.)
protected
string|null
$service
= null
$username
Username
protected
string
$username
= ''
Methods
__construct()
Constructor
public
__construct(string $host, int|string $port[, string $service = 'imap' ]) : mixed
Instantiate the IMAP mail client object
Parameters
- $host : string
- $port : int|string
- $service : string = 'imap'
clearMessageFlags()
Mark a message or messages as unread
public
clearMessageFlags(mixed $ids, string $flags[, int $options = ST_UID ]) : Imap
Parameters
- $ids : mixed
- $flags : string
- $options : int = ST_UID
Return values
Imapclose()
Close the mailbox connection resource
public
close() : void
connect()
Connect to an IMAP mailbox
public
static connect(array<string|int, mixed> $creds[, string|null $flags = null ][, int|null $options = null ][, int|null $retries = null ][, array<string|int, mixed>|null $params = null ]) : Imap
Parameters
- $creds : array<string|int, mixed>
- $flags : string|null = null
- $options : int|null = null
- $retries : int|null = null
- $params : array<string|int, mixed>|null = null
Return values
Imapconnection()
Get mailbox connection
public
connection() : mixed
copyMessage()
Copy messages to another mailbox
public
copyMessage(mixed $ids, string|array<string|int, mixed> $to[, int $options = CP_UID ]) : Imap
Parameters
- $ids : mixed
- $to : string|array<string|int, mixed>
- $options : int = CP_UID
Return values
ImapcreateMailbox()
Create mailbox
public
createMailbox(string $new) : Imap
Parameters
- $new : string
Return values
ImapdecodeText()
Decode text
public
decodeText(string $text) : string
Parameters
- $text : string
Return values
stringdeleteMailbox()
Delete mailbox
public
deleteMailbox([string|null $mailbox = null ]) : Imap
Parameters
- $mailbox : string|null = null
Tags
Return values
ImapdeleteMessage()
Delete message
public
deleteMessage(int|string $id[, int $options = FT_UID ]) : Imap
Parameters
- $id : int|string
- $options : int = FT_UID
Return values
ImapgetConnectionString()
Get mailbox connection string
public
getConnectionString() : string|null
Return values
string|nullgetFolder()
Get folder
public
getFolder() : string
Return values
stringgetHost()
Get mail client host
public
getHost() : string|null
Return values
string|nullgetInfo()
Get mailbox info
public
getInfo() : stdClass
Return values
stdClassgetMessageAttachments()
Get message parts by message ID
public
getMessageAttachments(int|string $id) : array<string|int, mixed>
Parameters
- $id : int|string
Return values
array<string|int, mixed>getMessageBody()
Get message body by message ID
public
getMessageBody(int|string $id) : string
Parameters
- $id : int|string
Return values
stringgetMessageBoundary()
Get message boundary by message ID
public
getMessageBoundary(int|string $id) : string|null
Parameters
- $id : int|string
Return values
string|nullgetMessageHeaderInfoById()
Get raw message headers by message ID
public
getMessageHeaderInfoById(int|string $id) : array<string|int, mixed>
Parameters
- $id : int|string
Return values
array<string|int, mixed>getMessageHeaders()
Get message headers from a mailbox
public
getMessageHeaders([string $criteria = 'ALL' ][, int $options = SE_UID ][, string|null $charset = null ]) : array<string|int, mixed>
Parameters
- $criteria : string = 'ALL'
- $options : int = SE_UID
- $charset : string|null = null
Return values
array<string|int, mixed>getMessageHeadersBy()
Get message headers from a mailbox
public
getMessageHeadersBy([int $criteria = SORTDATE ][, bool $reverse = true ][, int $options = SE_UID ][, string $search = 'ALL' ][, string|null $charset = null ]) : array<string|int, mixed>
Parameters
- $criteria : int = SORTDATE
- $reverse : bool = true
- $options : int = SE_UID
- $search : string = 'ALL'
- $charset : string|null = null
Return values
array<string|int, mixed>getMessageHeadersById()
Get message headers by message ID
public
getMessageHeadersById(int|string $id) : array<string|int, mixed>
Parameters
- $id : int|string
Return values
array<string|int, mixed>getMessageIds()
Get message IDs from a mailbox
public
getMessageIds([string $criteria = 'ALL' ][, int $options = SE_UID ][, string|null $charset = null ]) : array<string|int, mixed>
Parameters
- $criteria : string = 'ALL'
- $options : int = SE_UID
- $charset : string|null = null
Return values
array<string|int, mixed>getMessageIdsBy()
Get message IDs from a mailbox by a sort criteria
public
getMessageIdsBy([int $criteria = SORTDATE ][, bool $reverse = true ][, int $options = SE_UID ][, string $search = 'ALL' ][, s $charset = null ]) : array<string|int, mixed>
Parameters
- $criteria : int = SORTDATE
- $reverse : bool = true
- $options : int = SE_UID
- $search : string = 'ALL'
- $charset : s = null
Return values
array<string|int, mixed>getMessageNumber()
Get message number from UID
public
getMessageNumber(int|string $id) : int
Parameters
- $id : int|string
Return values
intgetMessageParts()
Get message parts by message ID
public
getMessageParts(int|string $id) : array<string|int, mixed>
Parameters
- $id : int|string
Return values
array<string|int, mixed>getMessageRawHeadersById()
Get raw message headers by message ID
public
getMessageRawHeadersById(int|string $id) : array<string|int, mixed>
Parameters
- $id : int|string
Return values
array<string|int, mixed>getMessageStructure()
Get message structure by message ID
public
getMessageStructure(int|string $id) : stdClass
Parameters
- $id : int|string
Return values
stdClassgetNumberOfMessages()
Get total number of messages
public
getNumberOfMessages() : int
Return values
intgetNumberOfReadMessages()
Get total number of read messages
public
getNumberOfReadMessages() : int
Return values
intgetNumberOfUnreadMessages()
Get total number of unread messages
public
getNumberOfUnreadMessages() : int
Return values
intgetOverview()
Get message overviews
public
getOverview(mixed $ids[, int $options = FT_UID ]) : array<string|int, mixed>
Parameters
- $ids : mixed
- $options : int = FT_UID
Return values
array<string|int, mixed>getPassword()
Get password
public
getPassword() : string
Return values
stringgetPort()
Get mail client port
public
getPort() : int|string|null
Return values
int|string|nullgetService()
Get mail client service
public
getService() : string|null
Return values
string|nullgetStatus()
Get mailbox status
public
getStatus() : stdClass
Return values
stdClassgetUsername()
Get username
public
getUsername() : string
Return values
stringhasMessageAttachments()
Get message parts by message ID
public
hasMessageAttachments(int|string $id[, string|null $encoding = null ]) : bool
Parameters
- $id : int|string
- $encoding : string|null = null
Return values
boolisOpen()
Determine if the mailbox connection has been opened
public
isOpen() : bool
Return values
boollistMailboxes()
List mailboxes
public
listMailboxes([string $pattern = '*' ]) : array<string|int, mixed>
Parameters
- $pattern : string = '*'
Return values
array<string|int, mixed>markAsRead()
Mark a message or messages as read
public
markAsRead(mixed $ids[, int $options = ST_UID ]) : Imap
Parameters
- $ids : mixed
- $options : int = ST_UID
Return values
ImapmarkAsUnread()
Mark a message or messages as unread
public
markAsUnread(mixed $ids[, int $options = ST_UID ]) : Imap
Parameters
- $ids : mixed
- $options : int = ST_UID
Return values
ImapmoveMessage()
Move messages to another mailbox
public
moveMessage(mixed $ids, string|array<string|int, mixed> $to[, int $options = CP_UID ]) : Imap
Parameters
- $ids : mixed
- $to : string|array<string|int, mixed>
- $options : int = CP_UID
Return values
Imapopen()
Open mailbox connection
public
open([string|null $flags = null ][, int|null $options = null ][, int|null $retries = null ][, array<string|int, mixed>|null $params = null ]) : Imap
Parameters
- $flags : string|null = null
- $options : int|null = null
- $retries : int|null = null
- $params : array<string|int, mixed>|null = null
Return values
ImaprenameMailbox()
Rename mailbox
public
renameMailbox(string $new[, string|null $old = null ]) : Imap
Parameters
- $new : string
- $old : string|null = null
Return values
ImapsetFolder()
Set folder
public
setFolder(string $folder) : AbstractMailClient
Parameters
- $folder : string
Return values
AbstractMailClientsetHost()
Set mail client host
public
setHost(string $host) : AbstractMailClient
Parameters
- $host : string
Return values
AbstractMailClientsetMessageFlags()
Mark a message or messages as read
public
setMessageFlags(mixed $ids, string $flags[, int $options = ST_UID ]) : Imap
Parameters
- $ids : mixed
- $flags : string
- $options : int = ST_UID
Return values
ImapsetPassword()
Set password
public
setPassword(string $password) : AbstractMailClient
Parameters
- $password : string
Return values
AbstractMailClientsetPort()
Set mail client port
public
setPort(int|string $port) : AbstractMailClient
Parameters
- $port : int|string
Return values
AbstractMailClientsetService()
Set mail client service
public
setService(string $service) : AbstractMailClient
Parameters
- $service : string
Return values
AbstractMailClientsetUsername()
Set username
public
setUsername(string $username) : AbstractMailClient
Parameters
- $username : string