Net_IMAP
[ class tree: Net_IMAP ] [ index: Net_IMAP ] [ all elements ]

Source for file test_IMAPProtocol.php

Documentation is available at test_IMAPProtocol.php

  1. <?
  2. //
  3. // +----------------------------------------------------------------------+
  4. // | PHP Version 4                                                        |
  5. // +----------------------------------------------------------------------+
  6. // | Copyright (c) 1997-2003 The PHP Group                                |
  7. // +----------------------------------------------------------------------+
  8. // | This source file is subject to version 2.02 of the PHP license,      |
  9. // | that is bundled with this package in the file LICENSE, and is        |
  10. // | available at through the world-wide-web at                           |
  11. // | http://www.php.net/license/2_02.txt.                                 |
  12. // | If you did not receive a copy of the PHP license and are unable to   |
  13. // | obtain it through the world-wide-web, please send a note to          |
  14. // | license@php.net so we can mail you a copy immediately.               |
  15. // +----------------------------------------------------------------------+
  16. // | Author: Damian Alejandro Fernandez Sosa <damlists@cnba.uba.ar>       |
  17. // +----------------------------------------------------------------------+
  18.  
  19.  
  20. /*
  21.  
  22. This sample shows the parsed returning of the IMAPProtocol methods
  23. this is only useful for testing and to low level IMAP access example
  24.  
  25.  
  26.  
  27. */
  28.  
  29.  
  30.  
  31.  
  32. require_once('Net/IMAPProtocol.php');
  33. error_reporting(E_ALL);
  34.  
  35.  
  36.  
  37.  
  38.  
  39. $user="user";
  40. $passwd="password";
  41. $host="localhost";
  42. $port="143";
  43.  
  44.  
  45. //you can create a file called passwords.php and store your $user,$pass,$host and $port values in it
  46. // or you can modify this script
  47. @require_once("../passwords.php");
  48.  
  49. $a= new  Net_IMAPProtocol();
  50.  
  51. $a->setDebug(true);
  52. //$a->setUnparsedResponse(true);
  53. //$a->setUnparsedResponse(false);
  54.  
  55. $aaa=$a->cmdConnect($host,$port);
  56.  
  57.  
  58. //Choose your auth method...
  59. //$aaa=$a->cmdAuthenticate($user,$passwd);
  60. //$aaa=$a->cmdAuthenticate($user,$passwd, "CRAM-MD5");
  61. $aaa=$a->cmdLogin($user,$passwd);
  62. //$aaa=$a->login($user,$passwd);
  63.  
  64.  
  65. //$aaa=$a->cmdSelect("user.damian");
  66. $aaa=$a->cmdSelect("inbox");
  67.  
  68.  
  69.  
  70.  
  71.  
  72. //$str="inbox.inbox3aaa &4eE-";
  73. //$str="inbox.&AOEA4QDh-";
  74.  
  75. echo "Method cmdCreate()\n";
  76. print_r($aaa=$a->cmdCreate($str));
  77.  
  78.  
  79. echo "Method cmdList()\n";
  80. print_r($aaa=$a->cmdList("","*"));
  81.  
  82.  
  83.  
  84.  
  85. //Returns the Auth Methods the IMAP server Has
  86. //print_r($aaa=$a->getServerAuthMethods());
  87. //print_r($aaa=$a->cmdFetch("4","(BODY[1.1])"));
  88. //print_r($aaa=$a->cmdFetch("4","(BODY[1])"));
  89. print_r($aaa=$a->cmdFetch("4","(RFC822.TEXT)"));
  90.  
  91.  
  92.  
  93.  
  94.  
  95. print_r($aaa=$a->cmdFetch("1","(BODY[HEADER] BODY[TEXT])"));
  96. print_r($aaa=$a->cmdFetch("1","BODY[HEADER]"));
  97.  
  98.  
  99.  
  100.  
  101.  
  102. print_r($aaa=$a->cmdFetch("15","FULL"));
  103. print_r($aaa=$a->cmdFetch("1:3","(FLAGS RFC822.SIZE UID ENVELOPE INTERNALDATE)"));
  104.  
  105.  
  106. //print_r($aaa=$a->cmdFetch("1:3","(FLAGS RFC822.SIZE UID INTERNALDATE)"));
  107.  
  108.  
  109. //$aaa=$a->cmdFetch("1","(FLAGS RFC822.SIZE UID ENVELOPE INTERNALDATE)");
  110. //print_r($aaa=$a->cmdFetch("1","(FLAGS RFC822.SIZE UID INTERNALDATE)"));
  111. //$aaa=$a->cmdFetch("1:3","BODY[HEADER.FIELDS (References)]");
  112. //$aaa=$a->cmdFetch("1","(UID RFC822.SIZE)");
  113. //$aaa=$a->cmdFetch("1:10","RFC822.SIZE");
  114. //$aaa=$a->cmdFetch("1:10","INTERNALDATE");
  115. //$aaa=$a->cmdFetch("2:6","BODY[TEXT]");
  116. //$aaa=$a->cmdFetch("1:3","(FLAGS)");
  117. //$aaa=$a->cmdFetch("26:32","BODY");
  118. //$aaa=$a->cmdFetch("26:29","BODY");
  119. //$aaa=$a->cmdFetch("1","RFC822");
  120. $aaa=$a->cmdFetch("28","BODY");
  121. //$aaa=$a->cmdFetch("1","BODYSTRUCTURE");
  122. //$aaa=$a->cmdFetch("27","BODYSTRUCTURE");
  123. //$aaa=$a->cmdFetch("1:100","BODYSTRUCTURE");
  124. $aaa=$a->cmdFetch("2:10","(RFC822.SIZE FLAGS INTERNALDATE)");
  125. //$aaa=$a->cmdFetch("1:10","INTERNALDATE");
  126. $aaa=$a->cmdFetch("1","ENVELOPE");
  127. $aaa=$a->cmdFetch("10,9:16","FLAGS");
  128. //$aaa=$a->cmdFetch("10","BODY[TEXT]");
  129. //$aaa=$a->cmdFetch("10","RFC822.HEADER");
  130. //$aaa=$a->cmdFetch("10","RFC822.TEXT");
  131. //$aaa=$a->cmdFetch("10","BODYSTRUCTURE");
  132. //$aaa=$a->cmdFetch("10","RFC822.HEADER");
  133. $aaa=$a->cmdFetch("1:4","(BODY[HEADER] FLAGS RFC822.SIZE INTERNALDATE)");
  134. //$aaa=$a->cmdFetch("1:4","(FLAGS RFC822.SIZE INTERNALDATE)");
  135. //$aaa=$a->cmdFetch("10","BODY[1]");
  136. //$aaa=$a->cmdFetch("1","RFC822.SIZE");
  137. //$aaa=$a->cmdFetch("10","ENVELOPE");
  138. //$aaa=$a->cmdFetch("10","RFC822");
  139. //$aaa=$a->cmdFetch("10","ENVELOPE");
  140. //$aaa=$a->cmdFetch("1:30","(RFC822.SIZE FLAGS)");
  141. //$aaa=$a->cmdFetch("1:30","FLAGS");
  142. //print_r($aaa=$a->cmdFetch(32,"FLAGS"));
  143. //print_r($aaa=$a->cmdFetch("1:3","(FLAGS RFC822.SIZE UID ENVELOPE INTERNALDATE)"));
  144. //print_r($aaa=$a->cmdFetch("1","(FLAGS RFC822.SIZE UID ENVELOPE INTERNALDATE)"));
  145. //print_r($aaa=$a->cmdFetch("10","ENVELOPE"));
  146. //print_r($aaa=$a->cmdFetch("10","FLAGS"));
  147. //$aaa=$a->cmdUidFetch("1","FLAGS");
  148.  
  149.  
  150. //print_r($aaa=$a->cmdCapability());
  151.  
  152. //print_r($aaa=$a->cmdStore("1:2","+FLAGS","\Deleted"));
  153.  
  154.  
  155.  
  156.  
  157.  
  158.  
  159.  
  160. echo "Method cmdCheck()\n";
  161. print_r($aaa=$a->cmdCheck());
  162.  
  163. //print_r($aaa=$a->cmdClose());
  164. echo "Method cmdNoop()\n";
  165. print_r($aaa=$a->cmdNoop());
  166.  
  167. echo "Method cmdRename()\n";
  168. print_r($aaa=$a->cmdRename("inbox.test2","inbox.test3"));
  169.  
  170. echo "Method cmdSubscribe()\n";
  171. print_r($aaa=$a->cmdSubscribe("inbox.test1"));
  172.  
  173.  
  174.  
  175.  
  176.  
  177.  
  178.  
  179.  
  180. echo "Method cmdStatus()\n";
  181. print_r($aaa=$a->cmdStatus("inbox","MESSAGES UNSEEN"));
  182.  
  183.  
  184.  
  185.  
  186. echo "Method cmdUnsubscribe()\n";
  187. print_r($aaa=$a->cmdUnsubscribe("inbox.test1"));
  188.  
  189. echo "Method cmdList()\n";
  190. print_r($aaa=$a->cmdList("","*"));
  191.  
  192. echo "Method cmdLsub()\n";
  193. print_r($aaa=$a->cmdLsub("*","*"));
  194. echo "Method cmdSearch()\n";
  195. print_r($aaa=$a->cmdSearch("ALL"));
  196.  
  197. echo "Method cmdUidSearch()\n";
  198. print_r($aaa=$a->cmdUidSearch("ALL"));
  199.  
  200. echo "Method cmdCopy()\n";
  201. print_r($aaa=$a->cmdCopy("1","inbox.test1"));
  202.  
  203.  
  204.  
  205.  
  206. echo "Method cmdGetQuota()\n";
  207. print_r($aaa=$a->cmdGetQuota("user.montoto"));
  208.  
  209.  
  210. echo "Method cmdMyRights()\n";
  211. print_r($aaa=$a->cmdMyRights("inbox"));
  212.  
  213.  
  214. echo "Method cmdListRights()\n";
  215. print_r($aaa=$a->cmdListRights("inbox","montoto"));
  216.  
  217. echo "Method cmdGetACL()\n";
  218. print_r($aaa=$a->cmdGetACL("user.montoto"));
  219.  
  220. echo "Method cmdSetQuota()\n";
  221. print_r($aaa=$a->cmdSetQuota("user.montoto","500000"));
  222.  
  223.  
  224. echo "Method cmdCheck()\n";
  225. print_r($aaa=$a->cmdCheck());
  226.  
  227.  
  228. echo "Method cmdCreate()\n";
  229. print_r($aaa=$a->cmdCreate("inbox.inbox3"));
  230.  
  231. echo "Method cmdStatus()\n";
  232. print_r($a->cmdStatus("inbox","MESSAGES UNSEEN"));
  233.  
  234. print_r($a->_serverSupportedCapabilities);
  235.  
  236. echo "Method cmdExamine()\n";
  237. print_r($aaa=$a->cmdExamine("inbox"));
  238.  
  239. echo "Method cmdStore()\n";
  240. print_r($aaa=$a->cmdStore("1:2","+FLAGS","\Deleted"));
  241.  
  242. echo "Method cmdExpunge()\n";
  243. print_r($a->cmdExpunge());
  244.  
  245.  
  246. echo "Check if the server has ANNOTATEMORE Support\n";
  247. if( $a->hasAnnotateMoreSupport() ){
  248.     echo "Yes the server has ANNOTATEMORE Support\n";
  249.     //print_r( $a->cmdGetAnnotation("inbox" , array("test"), "algo") );
  250.  
  251.     print_r( $a->cmdSetAnnotation("INBOX" , "/comment",array("value.priv"=>"My comment" ) ) );
  252.     print_r( $a->cmdGetAnnotation("INBOX" , "/comment","value.priv" ) );
  253. }
  254. else{
  255.     echo "The server has NOT ANNOTATEMORE Support\n";
  256.  
  257. }
  258.  
  259.  
  260.  
  261. //print_r($aaa);
  262. $aaa=$a->cmdLogout();
  263. //print_r($aaa);
  264.  
  265. ?>

Documentation generated on Mon, 11 Mar 2019 13:54:09 -0400 by phpDocumentor 1.4.4. PEAR Logo Copyright © PHP Group 2004.