Guest User

Untitled

a guest
Oct 4th, 2016
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.90 KB | None | 0 0
  1. `DEBUG IMAP: AUTHENTICATE PLAIN command result: A1 NO Uncorrect mailHost "XXXX" for mailbox userName`
  2.  
  3. DEBUG: setDebug: JavaMail version 1.5.6
  4. DEBUG: getProvider() returning javax.mail.Provider[STORE,imap,com.sun.mail.imap.IMAPStore,Oracle]
  5. DEBUG IMAP: mail.imap.fetchsize: 16384
  6. DEBUG IMAP: mail.imap.ignorebodystructuresize: false
  7. DEBUG IMAP: mail.imap.statuscachetimeout: 1000
  8. DEBUG IMAP: mail.imap.appendbuffersize: -1
  9. DEBUG IMAP: mail.imap.minidletime: 10
  10. DEBUG IMAP: closeFoldersOnStoreFailure
  11. DEBUG IMAP: trying to connect to host "XXX", port 143, isSSL false
  12. * OK IMAP4 ready
  13. A0 CAPABILITY
  14. * CAPABILITY IMAP4rev1 UIDPLUS AUTH=PLAIN STARTTLS
  15. A0 OK completed
  16. DEBUG IMAP: AUTH: PLAIN
  17. DEBUG IMAP: protocolConnect login, host="XXX", user=userName, password=<non-null>
  18. DEBUG IMAP: AUTHENTICATE PLAIN command trace suppressed
  19. DEBUG IMAP: AUTHENTICATE PLAIN command result: A1 NO Uncorrect mailHost "XXXX" for mailbox userName
  20. Exception in thread "main" javax.mail.AuthenticationFailedException: Uncorrect mailHost "XXXX" for mailbox userName
  21. at com.sun.mail.imap.IMAPStore.protocolConnect(IMAPStore.java:725)
  22. at javax.mail.Service.connect(Service.java:366)
  23. at javax.mail.Service.connect(Service.java:246)
  24. at javax.mail.Service.connect(Service.java:195)
  25. at main.Folders.main(Folders.java:108)
  26.  
  27. import java.util.Properties;
  28. import javax.mail.*;
  29. import com.sun.mail.imap.*;
  30.  
  31. /**
  32. * Demo app that exercises the Message interfaces.
  33. * List information about folders.
  34. *
  35. * @author John Mani
  36. * @author Bill Shannon
  37. */
  38.  
  39. public class folderlist {
  40. static String protocol = null;
  41. static String host = null;
  42. static String user = null;
  43. static String password = null;
  44. static String url = null;
  45. static String root = null;
  46. static String pattern = "%";
  47. static boolean recursive = false;
  48. static boolean verbose = false;
  49. static boolean debug = false;
  50.  
  51. public static void main(String argv[]) throws Exception {
  52. int optind;
  53. for (optind = 0; optind < argv.length; optind++) {
  54. if (argv[optind].equals("-T")) {
  55. protocol = argv[++optind];
  56. } else if (argv[optind].equals("-H")) {
  57. host = argv[++optind];
  58. } else if (argv[optind].equals("-U")) {
  59. user = argv[++optind];
  60. } else if (argv[optind].equals("-P")) {
  61. password = argv[++optind];
  62. } else if (argv[optind].equals("-L")) {
  63. url = argv[++optind];
  64. } else if (argv[optind].equals("-R")) {
  65. root = argv[++optind];
  66. } else if (argv[optind].equals("-r")) {
  67. recursive = true;
  68. } else if (argv[optind].equals("-v")) {
  69. verbose = true;
  70. } else if (argv[optind].equals("-D")) {
  71. debug = true;
  72. } else if (argv[optind].equals("--")) {
  73. optind++;
  74. break;
  75. } else if (argv[optind].startsWith("-")) {
  76. System.out.println(
  77. "Usage: folderlist [-T protocol] [-H host] [-U user] [-P password] [-L url]");
  78. System.out.println(
  79. "t[-R root] [-r] [-v] [-D] [pattern]");
  80. System.exit(1);
  81. } else {
  82. break;
  83. }
  84. }
  85. if (optind < argv.length)
  86. pattern = argv[optind];
  87.  
  88. // Get a Properties object
  89. Properties props = System.getProperties();
  90.  
  91. // Get a Session object
  92. Session session = Session.getInstance(props, null);
  93. session.setDebug(debug);
  94.  
  95. // Get a Store object
  96. Store store = null;
  97. Folder rf = null;
  98. if (url != null) {
  99. URLName urln = new URLName(url);
  100. store = session.getStore(urln);
  101. store.connect();
  102. } else {
  103. if (protocol != null)
  104. store = session.getStore(protocol);
  105. else
  106. store = session.getStore();
  107.  
  108. // Connect
  109. if (host != null || user != null || password != null)
  110. store.connect(host, user, password);
  111. else
  112. store.connect();
  113. }
  114.  
  115. // List namespace
  116. if (root != null)
  117. rf = store.getFolder(root);
  118. else
  119. rf = store.getDefaultFolder();
  120.  
  121. dumpFolder(rf, false, "");
  122. if ((rf.getType() & Folder.HOLDS_FOLDERS) != 0) {
  123. Folder[] f = rf.list(pattern);
  124. for (int i = 0; i < f.length; i++)
  125. dumpFolder(f[i], recursive, " ");
  126. }
  127.  
  128. store.close();
  129. }
  130.  
  131. static void dumpFolder(Folder folder, boolean recurse, String tab)
  132. throws Exception {
  133. System.out.println(tab + "Name: " + folder.getName());
  134. System.out.println(tab + "Full Name: " + folder.getFullName());
  135. System.out.println(tab + "URL: " + folder.getURLName());
  136.  
  137. if (verbose) {
  138. if (!folder.isSubscribed())
  139. System.out.println(tab + "Not Subscribed");
  140.  
  141. if ((folder.getType() & Folder.HOLDS_MESSAGES) != 0) {
  142. if (folder.hasNewMessages())
  143. System.out.println(tab + "Has New Messages");
  144. System.out.println(tab + "Total Messages: " +
  145. folder.getMessageCount());
  146. System.out.println(tab + "New Messages: " +
  147. folder.getNewMessageCount());
  148. System.out.println(tab + "Unread Messages: " +
  149. folder.getUnreadMessageCount());
  150. }
  151. if ((folder.getType() & Folder.HOLDS_FOLDERS) != 0)
  152. System.out.println(tab + "Is Directory");
  153.  
  154. /*
  155. * Demonstrate use of IMAP folder attributes
  156. * returned by the IMAP LIST response.
  157. */
  158. if (folder instanceof IMAPFolder) {
  159. IMAPFolder f = (IMAPFolder)folder;
  160. String[] attrs = f.getAttributes();
  161. if (attrs != null && attrs.length > 0) {
  162. System.out.println(tab + "IMAP Attributes:");
  163. for (int i = 0; i < attrs.length; i++)
  164. System.out.println(tab + " " + attrs[i]);
  165. }
  166. }
  167. }
  168.  
  169. System.out.println();
  170.  
  171. if ((folder.getType() & Folder.HOLDS_FOLDERS) != 0) {
  172. if (recurse) {
  173. Folder[] f = folder.list();
  174. for (int i = 0; i < f.length; i++)
  175. dumpFolder(f[i], recurse, tab + " ");
  176. }
  177. }
  178. }
  179. }
Add Comment
Please, Sign In to add comment