PageRenderTime 55ms CodeModel.GetById 28ms RepoModel.GetById 0ms app.codeStats 0ms

/ImapExample.php

https://github.com/Kastang/Imap
PHP | 115 lines | 10 code | 18 blank | 87 comment | 0 complexity | fdc0be5b1ca26822ee72bc515ff8e731 MD5 | raw file
  1. <?
  2. /**
  3. * This script provides a short example how to use the Imap Wrapper
  4. * class.
  5. *
  6. * For detailed inforamtion of the below functions, please read
  7. * the comments above the functions in Imap.php
  8. *
  9. * To test the functionality of any of the below functions,
  10. * remove the // comment lines.
  11. *
  12. * This script has only been tested with Gmail SSL Imap servers.
  13. *
  14. * @see Copyright information in Imap.php
  15. *
  16. * @author Josh Grochowski (josh[at]kastang[dot]com)
  17. */
  18. include("Imap.php");
  19. $host = "imap.gmail.com";
  20. $user = "__USERNAME__@gmail.com";
  21. $pass = "__PASSWORD__";
  22. $port = 993;
  23. $ssl = true;
  24. $folder = "INBOX";
  25. $t = new Imap($host, $user, $pass, $port, $ssl, $folder);
  26. /*
  27. * Returns an Associative Array containing the number of
  28. * recent, unread, and total messages
  29. */
  30. //print_r($t->getInboxInformation());
  31. /*
  32. * Returns an Associative Array containing the subject of
  33. * every email along with the Message Id of each individual
  34. * email.
  35. */
  36. //print_r($t->getMessageIds());
  37. /*
  38. * Given a new $host, $user, $pass, $port, $ssl, $folder inputs,
  39. * this function will disconnect from the old connection and open
  40. * a new connection to a specified server.
  41. *
  42. * For the sake of the example, I am using the same information.
  43. */
  44. //$t->changeLoginInfo($host, $user, $pass, $port, $ssl, $folder);
  45. /*
  46. * Returns an Associative Array containing detailed information
  47. * about a specific Message Id.
  48. */
  49. //print_r($t->getDetailedMessageInfo(2));
  50. /*
  51. * Parses a given Email address and returns an Array containing
  52. * the mailbox, host, and name of the given email address.
  53. */
  54. //$a = $t->getDetailedMessageInfo(2);
  55. //print_r($t->parseAddresses($a["reply"]));
  56. /*
  57. * Generate an email address to comply with RFC822 specifications.
  58. */
  59. //$u = "testusername";
  60. //$h = "samplehost.com";
  61. //$n = "TestFirst TestLastName";
  62. //echo $t->createAddress($u, $h, $n);
  63. /*
  64. * Deletes a message matching the given Message Id.
  65. */
  66. //$t->deleteMessage(2);
  67. /*
  68. * Returns an Array containing structural information about a given
  69. * Message Id.
  70. *
  71. * @see imap_fetchstructure (http://www.php.net/manual/en/function.imap-fetchstructure.php)
  72. */
  73. //print_r($t->getStructure(2));
  74. /*
  75. * Returns the body type of a given Message Id.
  76. */
  77. //echo $t->getBodyType(2);
  78. /*
  79. * Returns the encoding type of a given Message Id.
  80. */
  81. //echo $t->getEncodingType(2);
  82. /*
  83. * Given an encoded Base64 message, returns the decoded text.
  84. *
  85. * Encoded string reads: "Testing One Two Three"
  86. */
  87. //echo $t->decodeBase64("VGVzdGluZyBPbmUgVHdvIFRocmVl");
  88. /*
  89. * Given a new folder, will disconnect and reconnect to the specified
  90. * folder name.
  91. */
  92. //$t->changeFolder("NEW_FOLDER_NAME");
  93. /*
  94. * Disconnects an active imap connection
  95. */
  96. //$t->disconnect();
  97. ?>