Documentation

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
category

Pop

author

Nick Sagona, III dev@nolainteractive.com

copyright

Copyright (c) 2009-2024 NOLA Interactive, LLC. (http://www.nolainteractive.com)

license

http://www.popphp.org/license New BSD License

version
4.0.0

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

$service

Mail client service (pop, imap, nntp, etc.)

protected string|null $service = null

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
Imap

close()

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
Imap

connection()

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
Imap

createMailbox()

Create mailbox

public createMailbox(string $new) : Imap
Parameters
$new : string
Return values
Imap

decodeText()

Decode text

public decodeText(string $text) : string
Parameters
$text : string
Return values
string

deleteMailbox()

Delete mailbox

public deleteMailbox([string|null $mailbox = null ]) : Imap
Parameters
$mailbox : string|null = null
Tags
throws
Exception
Return values
Imap

deleteMessage()

Delete message

public deleteMessage(int|string $id[, int $options = FT_UID ]) : Imap
Parameters
$id : int|string
$options : int = FT_UID
Return values
Imap

getConnectionString()

Get mailbox connection string

public getConnectionString() : string|null
Return values
string|null

getHost()

Get mail client host

public getHost() : string|null
Return values
string|null

getInfo()

Get mailbox info

public getInfo() : stdClass
Return values
stdClass

getMessageAttachments()

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
string

getMessageBoundary()

Get message boundary by message ID

public getMessageBoundary(int|string $id) : string|null
Parameters
$id : int|string
Return values
string|null

getMessageHeaderInfoById()

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
int

getMessageParts()

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
stdClass

getNumberOfMessages()

Get total number of messages

public getNumberOfMessages() : int
Return values
int

getNumberOfReadMessages()

Get total number of read messages

public getNumberOfReadMessages() : int
Return values
int

getNumberOfUnreadMessages()

Get total number of unread messages

public getNumberOfUnreadMessages() : int
Return values
int

getOverview()

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>

getPort()

Get mail client port

public getPort() : int|string|null
Return values
int|string|null

getService()

Get mail client service

public getService() : string|null
Return values
string|null

getStatus()

Get mailbox status

public getStatus() : stdClass
Return values
stdClass

hasMessageAttachments()

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
bool

isOpen()

Determine if the mailbox connection has been opened

public isOpen() : bool
Return values
bool

listMailboxes()

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
Imap

markAsUnread()

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
Imap

moveMessage()

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
Imap

open()

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
Imap

renameMailbox()

Rename mailbox

public renameMailbox(string $new[, string|null $old = null ]) : Imap
Parameters
$new : string
$old : string|null = null
Return values
Imap

setMessageFlags()

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
Imap

        
On this page

Search results