The IMAP (Internet Message Access Protocol) support allow to interact from PHP with a IMAP server. It can read, after authentication, the user mailbox and drive it.
The server can be secured by SSL. Then the IMAPS protocol is used, with a parameter to check or not the server certificate.
It can list, read the mails, move or delete one or multiple ones. It manage the folders (list, add, delete, subscribe, unsubscribe). It is also capable to read the quota state and define the mail flags.
Namespace Domframework
/** IMAP connection abstraction In the IMAP terminology, "mailbox" is a folder in the mailbox of the user
/** The auto expunge feature, after deleting/moving an email
/** The constructor The IMAP standard port is 143, but SSL tunnelled is 993@param string|null $imapserver
The IMAP server to connect. Localhost is used if not defined@param integer|null $imapport
The IMAP port to connect. 143 is used if not defined@param string|null $username
The username to connect@param string|null $password
The password to connect@param boolean|null $imapssl
Use the SSL connection layer. Not used by default@param boolean|null $imapcertvalidate
Check the certificates if using the SSL connection. True by default
/**
Add a subscription for a folder. The folder must be in UTF-8
@param string $folder
Add the provided folder to the subscription file of
the user
/**
Change to provided folder
The folder name must be in UTF-8. The folder must be absolute
@param string $folder
Change to the provided folder
/** The connect can be used when extends the imap class. The constructor can be override by the child class. The IMAP standard port is 143, but SSL tunnelled is 993@param string|null $imapserver
The IMAP server to connect. Localhost is used if not defined@param integer|null $imapport
The IMAP port to connect. 143 is used if not defined@param string|null $username
The username to connect@param string|null $password
The password to connect@param boolean|null $imapssl
Use the SSL connection layer. Not used by default@param boolean|null $imapcertvalidate
Check the certificates if using the SSL connection. True by default
/**
Create a new folder, provided in UTF-8. The folder must be absolute
@param string $folder
Create the provided folder
/**
Remove a subscription for a folder. The folder must be in UTF-8
@param string $folder
Remove the provided folder to the subscription file
of the user
/**
Delete an existing folder provided in UTF-8. The folder must be absolute
@param string $folder
The folder to delete
/** Expunge the mailbox. If the autoexpunge is activated, it is normally not needed
/** Return an array of the existing folders. The sub-folders are with slash separator The names of folders are converted in UTF-8
/** Return an array with folder name in key and attributes in value. The attributes allow to see if there is new mails in folders
/**
Get all the body (and attached files) of an email in raw format
@param integer $msgno
The message number to examine
/**
Get the headers of the email (in raw format)
@param integer $msgno
The message number to examine
/**
Get an existing email in the current folder in raw format
@param integer $msgno
The message number to examine
/** Return the current folder in UTF-8
/**
Return the information concerning a folder. It return an object with the
following properties :
Date date of last change (current datetime)
Driver driver
Mailbox name of the mailbox
Nmsgs number of messages
Recent number of recent messages
Unread number of unread messages
Deleted number of deleted messages
Size mailbox size
@param string $folder
The folder to get the informations
/** Return the quota used by the user in Mo
/**
Return email structure of the body
@param integer $msgno
The message number to examine
/** Return the content of a part of the mail body defined in the structure in an object, with the associated mimetype, the parameters like the charset if they are defined, the number of lines associated to this part in the mail and some other info@param integer $msgno
The message number to examine@param integer $part
The message part to get
/**
Return the part identifiers of the structure of the mail body. To be used
in getStructureContent
@param integer $msgno
The message number to examine
/**
Return the structure of the mail body with the associated content
@param integer $msgno
The message number to examine
/** Return the list of the folders substcribed by the user. The folders are in UTF-8
/** Return an array of mailHeaders order by $field and by order ASC or DESC@param array $mailHeaders
The headers to sort@param string $field
The field to examine@param boolean|null $orderAsc
The order of sorting. Asc if not defined
/**
Add a new mail in the current folder. The content must be a string
containing all the mail (header and body). If the content is invalid, the
directory listing can provide erroneous data
@param string $content
the content of the mail to add
/** Copy the mail provided in the $folder in UTF-8. If $msgno is an array, all the mails with the contain msgno are copied@param integer|array $msgno
The message number(s) to copy@param string $folder
The destination folder of the copy. Must exists
/** Move the mail provided in the $folder in UTF-8. If $msgno is an array, all the mails with the contain msgno are deleted Expunge automatically the current folder to remove the old emails@param integer|array $msgno
The message number(s) to copy@param string $folder
The destination folder of the move. Must exists
/** Fetch the headers for all messages in the current folder sorted by date Return an array of mail object containing information like the subject, the date, if the message is already read (recent), answered... (see http://www.php.net/manual/en/function.imap-fetch-overview.php) If the $from is negative, take the LAST $from mails If from is zero, it's value is override to 1 For information, takes 0.4s to select 30 mails on 1552@param integer|null $from
The selector of the mails. 1 if not defined@param integer|null $nbmails
The number of mails returned by the method 30 if not defined
/**
Delete all the mailIDs (msgno) provided in an array or a single mail if
$msgno is not an array
DO NOT MOVE THE MAIL IN TRASH, DESTROY THE MAIL REALLY
Expunge the mails at the end of the operation
@param array|integer $msgno
The message number(s) to remove
/** Send back the number of mails in the mailbox
/**
Return an array containing the msgno corresponding to the criteria
@param string $criteria
The criteria to use for the IMAP search
/** Return all the mails numbers order by thread in an array. [] => array ("msgno"=>msgno, "depth"=>depth)
/**
Mark mail(s) as read.
If msgno is an array, a list of mails will be modified.
If msgno is an integer, only one mail will be modified
@param integer|array $msgno
The messages number(s) to mark as read
/**
Mark mail(s) as unread.
If msgno is an array, a list of mails will be modified.
If msgno is an integer, only one mail will be modified
@param integer|array $msgno
The messages number(s) to mark as unread
/** Set the flags of the msgno. If msgno is an array, the flags will be write on the list of mails. The others flags of the email are not modified. The flags must be an array containing : \Seen Message has been read \Answered Message has been answered \Flagged Message is "flagged" for urgent/special attention \Deleted Message is "deleted" for removal by later EXPUNGE \Draft Message has not completed composition (marked as a draft).@param integer|array $msgno
The messages number(s) to add the flags@param array $flags
The flags to add
/** Unset the flags of the msgno. If msgno is an array, the flags will be write on the list of mails. The others flags of the email are not modified. The flags must be an array containing : \Seen Message has been read \Answered Message has been answered \Flagged Message is "flagged" for urgent/special attention \Deleted Message is "deleted" for removal by later EXPUNGE \Draft Message has not completed composition (marked as a draft).@param integer|array $msgno
The messages number(s) to remove the flags@param array $flags
The flags to remove