Repository navigation
Expand file tree
/
Copy pathparams.json
More file actions
6 lines (6 loc) · 7.45 KB
/
Copy pathparams.json
File metadata and controls
6 lines (6 loc) · 7.45 KB
1
2
3
4
5
6
{
"name": "Php-libimap",
"tagline": "PHP libimap is a PHP imap library in pure OOP, the idea is to make the native php_imap functions easier to use with performance tunning in mind.",
"body": "# php-libimap\r\nphp-libimap is a PHP imap library in pure OOP, the idea is to make the native php_imap functions easier to use with performance tunning in mind.\r\n\r\n\r\n\r\n###Installation\r\nusing composer , include this in your ***composer.json*** file :\r\n\r\n```json\r\n\"razzbee/php-libimap\" : \"dev-master\"\r\n```\r\n\r\n###Usage \r\n\r\n####Initialise class\r\n\r\n```php\r\n$imap = new \\PHPLibImap\\IMAP;\r\n```\r\n\r\n**connect an imap server**\r\n\r\n\r\n```php\r\n$imap->connectServer([\r\n 'host' => 'localhost',\r\n 'port' => 993,\r\n 'imap_username' => 'username@domain.tld',\r\n 'password' => 'secret',\r\n 'mailbox_name' => 'INBOX',\r\n 'enableSSL' => true,\r\n]);\r\n```\r\n\r\n**host** : Your Imap mail server hostname , example : localhost , 19.10.10.2 , imap.domain.tld or domain.tld \r\n\r\n\r\n**port** : your mailserver's imap's port , the default for secure connection is 993 and no secure connection is 143\r\n\r\n\r\n**imap_username** : The full qualified email address of mail account , example: you@example.com \r\n\r\n\r\n**password** : your mail account password.\r\n\r\n\r\n**mailbox_name** : (optional) , the mailbox to open on an initial connection, if non is specified, INBOX will be used.\r\n\r\n\r\n**enableSSL** : (optional) , This is for those using a custom port, so that the library will know if the port needs a secure connection \r\n\r\n\r\n\r\n###Switching Mailbox \r\nAfter Connecting to the server, the optional mailbox_name supplied in the connection parameters is opened automatically , you can change or switch mailbox using \r\n\r\n```php\r\n$imap-> switchMailBox('mailbox_name');\r\n```\r\nthe mailbox_name must be one of the names of the mailfolders or boxes in your mailserver , example: INBOX , Drafts , Spam or Trash \r\n\r\n###Fetch MailBoxes (Mail Folders) \r\n\r\nYou can also list available mail boxes in mailserver \r\n\r\n```php\r\n$mailBoxes = $imap->getMailBoxes($pattern);\r\n```\r\n\r\n$pattern: (optional) This is either \\* or % where :\r\n\r\n\r\n\\* Means the library should fetch all the mailboxes including top level mail boxes and sub folders\r\n\r\n\r\n**%** Means the library should fetch all sub folders in the current mailbox \r\n\r\n\r\nread more here : http://php.net/manual/en/function.imap-getmailboxes.php\r\n\r\n\r\n\r\n\r\n###Get Info About a mailbox \r\n\r\n```php\r\n$mailBoxInfo = $imap->getMailBoxInfo($mailboxName=null,$forceNew=false);\r\n```\r\n\r\n**$mailBoxName**: (optional) the name of the mailbox you want the info about, it defaults to the current opened mailbox if not set\r\n\r\n**$forceNew** : (optional) The mailbox info is always prefetched and kept, but if you want a fresh copy of the info to be refetched , set this to true ..\r\n\r\n\r\n\r\n***Count Total Recent Messages***\r\n```php\r\n$totalRecent = $imap->getMailBoxInfo()->recent;\r\n```\r\n\r\n###Count Total Unread Messages In the MailBox \r\n\r\n```php\r\n$totalMsgNo = $imap->getTotalMessages();\r\n\r\n//or\r\n\r\n$totalMsgNo = $imap->getMailBoxInfo()->messages;\r\n```\r\n\r\n###Fetch Mails From a MailBox \r\nThis library has many ways to fetch mails from a mailbox , we have also optimized this particular feature for speed and performance ..\r\n\r\n####Fetch MailBox Items overview By UID \r\n\r\n```php\r\n$mails = $imap->fetchMailBoxItems(\"mailbox_name\")\r\n ->select(uid1,uid2,uid3,uid4...uidN)\r\n\t\t\t ->getResults();\r\n```\r\n\r\n\r\n**mailbox_name** : optional mailbox name , if none is supplied, the current opened mailboxed will be used \r\n\r\n**select(uid1,uid2, ... )**: Select mail headers by the uid or the integer id(s) of the mail(s) , you must provide a valid uid else an exception will be generated \r\n\r\n\r\n**getResults** : Generate and get the results \r\n\r\n\r\n####Fetch Mail Overview using range \r\n```php\r\n$mails = $imap->fetchMailBoxItems(\"mailbox_name\")\r\n ->range(1,10)\r\n\t\t\t ->orderById('desc')\r\n\t\t\t ->getResults();\r\n```\r\n\r\n**range(arg1,arg2)** : The range of mail uid , the above example will pull mailbox item overview info of uid 1 to 10 , This method assumes you already know your range already..\r\n\r\n**orderById** : Order the results by the uid , the default is DESC (Descending Order), this means the latest mails overview info will be shown first\r\n\r\n\r\n####Fetch Mail Overview using limit and Offset \r\nLike mysql limit and offset , this library supports the limit and offset using the limit($limit,$offset) method..\r\n```php\r\n$mails = $imap->fetchMailBoxItems(\"mailbox_name\")\r\n ->limit(1,10)\r\n\t\t\t ->orderById('desc')\r\n\t\t\t ->getResults();\r\n```\r\n***limit($limit,$offset=0)*** : The limit method accepts two arguments the limit and offset ,internally , the limits and offsets are been calculated automatically to ranges , this method is safer to use if you have no idea about the range values or number of data in the mailbox. The offset is optional and defaults to 0\r\n\r\n####Move Mail Between Mailboxes \r\n\r\nThis method moves email message between mailboxes or folder, on success true is returned else false,an exception will also occur on error ..\r\n\r\n```php\r\n$move = $imap->moveMail($mails_uids_array,$source_mailbox,$destination_mailbox,$expunge=false);\r\n```\r\n\r\n***$mails_uids_array*** : The mail(s) numeric uid in an array , it can contain 1 or more valid ids \r\n\r\n***$source_mailbox*** : The name of the mailbox where the mail is currently located at , example : INBOX , Drafts ...\r\n\r\n***$destination_mailbox*** : The Name of the new mail box you want to move the mail into , Example : Spam, drafts ....\r\n\r\n***$expunge*** : Optional boolean which tells the library to perform immediate clean up or deletion of the email at the source mailbox after moving \r\n\r\n###Mark as Mail as seen , answered , deleted , draft or flagged\r\n```php \r\n$setFlag = $imap->setFlag($mails_uids_array,$flag,$mailBoxName);\r\n```\r\n***$mails_uids_array*** : The mail(s) numeric uid in an array , it can contain 1 or more valid ids \r\n\r\n***$flag***: The flag to set to ,valid flags : seen , answered, deleted , draft or flagged \r\n\r\n***$mailBoxName*** : Mailbox name of the mails you want to set the flags to if not provided , current opened mailbox will be used \r\n\r\n####Search Mail \r\nSearch into mailbox using a given criteria , use the getResults() method to retrive the results\r\n```php \r\n $keyword = \"hello\";\r\n\t\t \r\n //body must contain at least one occurrance of the keyword\r\n $searchCritiria['BODY'] = $keyword;\r\n\t\t\r\n //subject too must contain at least one occurrance of the keyword \r\n $searchCritiria['SUBJECT'] = $keyword;\r\n\t\t\r\n\t\t$mailBoxName = \"INBOX\";\r\n\t\t\r\n $searchResults = $imap\r\n ->search($searchCritiria,$mailBoxName)\r\n ->limit(20)\r\n ->getResults();\r\n```\r\n***$keyword*** The string we want to search for \r\n\r\n***$searchCritiria*** : The search Criteria which will be used for the search , read more about the criteria here : http://php.net/manual/en/function.imap-search.php\r\n\r\n***$mailBoxName***: Optional Mailbox Name where you want to search into , if the mailbox name is omitted , the current opened mailbox will be used \r\n\r\n",
"note": "Don't delete this file! It's used internally to help with page regeneration."
}