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

Documentation generated on Mon, 11 Mar 2019 15:56:41 -0400 by phpDocumentor 1.4.4. PEAR Logo Copyright © PHP Group 2004.