我正在尝试使用Java mail api开发电子邮件侦听器。我两次收到同样的电子邮件,每次都没有发生这种情况;随机发生。
以下代码用于进行IMAP连接
try {
isConnecting.set(true);
createSession();
LOGGER.warn("session created "+getIdentifier() +"on Imap"+imapLoginId+" pw "+imapPasswrd);
store = session.getStore("imap");
if(store==null){
LOGGER.warn("store is null return from here"+getIdentifier() +"on Imap"+imapLoginId+" pw "+imapPasswrd);
return;
}
store.connect(imapServerAddress, imapLoginId, imapPasswrd);
LOGGER.warn("Connecting successful "+getIdentifier() +"on Imap"+imapLoginId+" pw "+imapPasswrd);
folder = store.getFolder(folderName);
LOGGER.warn("Folder creating "+getIdentifier() +"on Imap"+imapLoginId+" pw "+imapPasswrd);
if (timer == null) {
timer = new HashedWheelTimer(1, TimeUnit.SECONDS);
}
if (idleManager == null) {
idleManager = new IdleManager(session, es);
}
if (folder == null || !folder.exists()) {
LOGGER.warn("invalid folder exit from here "+getIdentifier() +"on Imap"+imapLoginId+" pw "+imapPasswrd);
System.out.println("Invalid folder");
return;
}
synchronized (folder) {
LOGGER.warn("Folder sync "+getIdentifier() +"on Imap"+imapLoginId+" pw "+imapPasswrd);
folder.addConnectionListener(this);
folder.open(Folder.READ_WRITE);
folder.addMessageCountListener(this);
System.out.println("message count listener added");
LOGGER.warn("message count listner added "+getIdentifier() +"on Imap"+imapLoginId+" pw "+imapPasswrd);
if (folder instanceof IMAPFolder) {
IMAPFolder f = (IMAPFolder) folder;
System.out.println("enter idle");
LOGGER.warn("Idle condition "+getIdentifier() +"on Imap"+imapLoginId+" pw "+imapPasswrd);
idleManager.watch(f);
setIsConnected(true);
LOGGER.warn("Folder.watch "+getIdentifier() +"on Imap"+imapLoginId+" pw "+imapPasswrd);
DbUtil.updateMediaStream(getIdentifier(), true);
isConnecting.set(false);
connectionAttempt.set(0);
LOGGER.warn("Db updated "+getIdentifier() +"on Imap"+imapLoginId+" pw "+imapPasswrd);
System.out.println("idle done");
scheduleTask();
LOGGER.warn("Scheduler starts "+getIdentifier() +"on Imap"+imapLoginId+" pw "+imapPasswrd);
}
}
System.out.println(new Date()
+ "================================== connect() end");
LOGGER.warn("____________________END connecting "+getIdentifier() +"on Imap"+imapLoginId+" pw "+imapPasswrd);
} catch (Exception fex) {
if (connectionAttempt.get() >= 3) {
LOGGER.error("Reconnection Failed", fex);
connectionAttempt.set(0);
throw new IllegalStateException(
"Error while connecting mediaStream", fex);
}
LOGGER.error("Reconnecting mediastream attempt "
+ connectionAttempt.get(), fex);
connectionAttempt.incrementAndGet();
closeFolderAndStore();
connect();
}
此处收到电子邮件,“public void messagesAdded(MessageCountEvent ev)”方法调用两次
@Override
public void messagesAdded(MessageCountEvent ev) {
Message[] msgs = ev.getMessages();
System.out.println("Got " + msgs.length + " new messages");
LOGGER.info("New message received {}" ,msgs.length);
// Just dump out the new messages
for (int i = 0; i < msgs.length; i++) {
try {
// msgs[i].writeTo(System.out);
System.out.println("-----");
System.out.println("Message >>" + msgs[i].getMessageNumber()
+ ":");
LOGGER.info("Email Received >>> {}" , msgs[i].getMessageNumber());
processEmail(msgs[i]);
} catch (Exception ioex) {
LOGGER.error("messagesAdded:getmessagenumber", ioex);
ioex.printStackTrace();
}
}
try {
synchronized (folder) {
if (folder != null && idleManager != null) {
idleManager.watch(folder);
}
}
} catch (Exception e) {
LOGGER.error("messagesAdded:watch", e);
e.printStackTrace();
}
}
IMAP调试日志如下
DEBUG: getProvider() returning javax.mail.Provider[STORE,imap,com.sun.mail.imap.IMAPStore,Oracle]
DEBUG IMAP: mail.imap.fetchsize: 16384
DEBUG IMAP: mail.imap.ignorebodystructuresize: false
DEBUG IMAP: mail.imap.statuscachetimeout: 1000
DEBUG IMAP: mail.imap.appendbuffersize: -1
DEBUG IMAP: mail.imap.minidletime: 10
DEBUG IMAP: enable STARTTLS
DEBUG IMAP: closeFoldersOnStoreFailure
DEBUG IMAP: trying to connect to host "outlook.office365.com", port 993, isSSL true
* OK The Microsoft Exchange IMAP4 service is ready. [QQBNADMAUABSADAANQBDAEEAMAAyADgALgBlAHUAcgBwAHIAZAAwADUALgBwAHIAbwBkAC4AbwB1AHQAbABvAG8AawAuAGMAbwBtAA==]
A0 CAPABILITY
* CAPABILITY IMAP4 IMAP4rev1 AUTH=PLAIN AUTH=XOAUTH2 SASL-IR UIDPLUS MOVE ID UNSELECT CHILDREN IDLE NAMESPACE LITERAL+
A0 OK CAPABILITY completed.
DEBUG IMAP: AUTH: PLAIN
DEBUG IMAP: AUTH: XOAUTH2
DEBUG IMAP: protocolConnect login, host=outlook.office365.com, user=amith.bharathan@drd.co.in, password=<non-null>
DEBUG IMAP: AUTHENTICATE PLAIN command trace suppressed
DEBUG IMAP: AUTHENTICATE PLAIN command result: A1 OK AUTHENTICATE completed.
A2 CAPABILITY
* CAPABILITY IMAP4 IMAP4rev1 AUTH=PLAIN AUTH=XOAUTH2 SASL-IR UIDPLUS MOVE ID UNSELECT CLIENTACCESSRULES CLIENTNETWORKPRESENCELOCATION BACKENDAUTHENTICATE CHILDREN IDLE NAMESPACE LITERAL+
A2 OK CAPABILITY completed.
DEBUG IMAP: AUTH: PLAIN
DEBUG IMAP: AUTH: XOAUTH2
A3 LIST "" inbox
DEBUG IMAP: IdleManager select starting
DEBUG IMAP: IdleManager waiting...
* LIST (\Marked \HasNoChildren) "/" INBOX
A3 OK LIST completed.
DEBUG IMAP: connection available -- size: 1
A4 SELECT INBOX
* 463 EXISTS
* 0 RECENT
* FLAGS (\Seen \Answered \Flagged \Deleted \Draft $MDNSent)
* OK [PERMANENTFLAGS (\Seen \Answered \Flagged \Deleted \Draft $MDNSent)] Permanent flags
* OK [UNSEEN 36] Is the first unseen message
* OK [UIDVALIDITY 14] UIDVALIDITY value
* OK [UIDNEXT 7207] The next unique identifier value
A4 OK [READ-WRITE] SELECT completed.
DEBUG IMAP: IdleManager watching imap://amith.bharathan%40drd.co.in@outlook.office365.com/INBOX
A5 IDLE
+ IDLE accepted, awaiting DONE command.
DEBUG IMAP: startIdle: set to IDLE
DEBUG IMAP: startIdle: return true
DEBUG IMAP: IdleManager.watch startIdle succeeded for imap://amith.bharathan%40drd.co.in@outlook.office365.com/INBOX
DEBUG IMAP: IdleManager selected 0 channels
DEBUG IMAP: IdleManager adding imap://amith.bharathan%40drd.co.in@outlook.office365.com/INBOX to selector
DEBUG IMAP: IdleManager waiting...
DEBUG IMAP: IdleManager selected 1 channels
DEBUG IMAP: IdleManager selected folder: imap://amith.bharathan%40drd.co.in@outlook.office365.com/INBOX
* 1 RECENT
* 464 EXISTS
DEBUG IMAP: waitIfIdle: request IdleManager to abort
DEBUG IMAP: waitIfIdle: wait to be not idle: Thread[pool-21-thread-2,5,main]
DEBUG IMAP: IdleManager continue watching folder imap://amith.bharathan%40drd.co.in@outlook.office365.com/INBOX
DEBUG IMAP: IdleManager aborting IDLE for folder: imap://amith.bharathan%40drd.co.in@outlook.office365.com/INBOX
DONE
DEBUG IMAP: IdleManager adding imap://amith.bharathan%40drd.co.in@outlook.office365.com/INBOX to selector
DEBUG IMAP: IdleManager adding imap://amith.bharathan%40drd.co.in@outlook.office365.com/INBOX to selector
DEBUG IMAP: IdleManager waiting...
DEBUG IMAP: IdleManager selected 1 channels
DEBUG IMAP: IdleManager selected folder: imap://amith.bharathan%40drd.co.in@outlook.office365.com/INBOX
A5 OK IDLE completed.
DEBUG IMAP: handleIdle: set to RUNNING
DEBUG IMAP: waitIfIdle: wait done, idleState 0: Thread[pool-21-thread-2,5,main]
A6 FETCH 464 (ENVELOPE INTERNALDATE RFC822.SIZE)
DEBUG IMAP: IdleManager done watching folder imap://amith.bharathan%40drd.co.in@outlook.office365.com/INBOX
DEBUG IMAP: IdleManager waiting...
* 464 FETCH (ENVELOPE ("Wed, 29 Jun 2016 08:31:06 +0000" "4444" (("Amith K Bharathan" NIL "amith.bharathan" "drd.co.in")) NIL NIL (("Amith K Bharathan" NIL "amith.bharathan" "drd.co.in")) NIL NIL NIL "<HE1PR06MB1196D2A9F2FDB040AB2B05B5BF230@HE1PR06MB1196.eurprd06.prod.outlook.com>") INTERNALDATE "29-Jun-2016 14:01:07 +0530" RFC822.SIZE 19822)
A6 OK FETCH completed.
A7 FETCH 464 (BODYSTRUCTURE)
* 464 FETCH (BODYSTRUCTURE ("text" "html" ("charset" "us-ascii") NIL NIL "7BIT" 1586 48 NIL NIL "en-US" NIL))
A7 OK FETCH completed.
A8 FETCH 464 (BODY[TEXT]<0.1586>)
* 464 FETCH (BODY[TEXT]<0> {1586}
<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
<meta name="Generator" content="Microsoft Word 14 (filtered medium)">
<style><!--
/* Font Definitions */
@font-face
{font-family:Calibri;
panose-1:2 15 5 2 2 2 4 3 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
{margin:0in;
margin-bottom:.0001pt;
font-size:11.0pt;
font-family:"Calibri","sans-serif";}
a:link, span.MsoHyperlink
{mso-style-priority:99;
color:blue;
text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
{mso-style-priority:99;
color:purple;
text-decoration:underline;}
span.EmailStyle17
{mso-style-type:personal-compose;
font-family:"Calibri","sans-serif";
color:windowtext;}
.MsoChpDefault
{mso-style-type:export-only;
font-family:"Calibri","sans-serif";}
@page WordSection1
{size:8.5in 11.0in;
margin:1.0in 1.0in 1.0in 1.0in;}
div.WordSection1
{page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]-->
</head>
<body lang="EN-US" link="blue" vlink="purple">
<div class="WordSection1">
<p class="MsoNormal">555555555555<o:p></o:p></p>
</div>
</body>
</html>
FLAGS (\Seen \Recent))
A8 OK FETCH completed.
A9 FETCH 464 (BODY[TEXT]<0.1586>)
* 464 FETCH (BODY[TEXT]<0> {1586}
<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
<meta name="Generator" content="Microsoft Word 14 (filtered medium)">
<style><!--
/* Font Definitions */
@font-face
{font-family:Calibri;
panose-1:2 15 5 2 2 2 4 3 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
{margin:0in;
margin-bottom:.0001pt;
font-size:11.0pt;
font-family:"Calibri","sans-serif";}
a:link, span.MsoHyperlink
{mso-style-priority:99;
color:blue;
text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
{mso-style-priority:99;
color:purple;
text-decoration:underline;}
span.EmailStyle17
{mso-style-type:personal-compose;
font-family:"Calibri","sans-serif";
color:windowtext;}
.MsoChpDefault
{mso-style-type:export-only;
font-family:"Calibri","sans-serif";}
@page WordSection1
{size:8.5in 11.0in;
margin:1.0in 1.0in 1.0in 1.0in;}
div.WordSection1
{page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]-->
</head>
<body lang="EN-US" link="blue" vlink="purple">
<div class="WordSection1">
<p class="MsoNormal">555555555555<o:p></o:p></p>
</div>
</body>
</html>
FLAGS (\Seen \Recent))
A9 OK FETCH completed.
DEBUG IMAP: IdleManager watching imap://amith.bharathan%40drd.co.in@outlook.office365.com/INBOX
A10 IDLE
+ IDLE accepted, awaiting DONE command.
DEBUG IMAP: startIdle: set to IDLE
DEBUG IMAP: startIdle: return true
DEBUG IMAP: IdleManager.watch startIdle succeeded for imap://amith.bharathan%40drd.co.in@outlook.office365.com/INBOX
DEBUG IMAP: IdleManager selected 0 channels
DEBUG IMAP: IdleManager adding imap://amith.bharathan%40drd.co.in@outlook.office365.com/INBOX to selector
DEBUG IMAP: IdleManager waiting...
DEBUG IMAP: IdleManager selected 1 channels
DEBUG IMAP: IdleManager selected folder: imap://amith.bharathan%40drd.co.in@outlook.office365.com/INBOX
* 2 RECENT
* 465 EXISTS
DEBUG IMAP: waitIfIdle: request IdleManager to abort
DEBUG IMAP: waitIfIdle: wait to be not idle: Thread[pool-21-thread-2,5,main]
DEBUG IMAP: IdleManager continue watching folder imap://amith.bharathan%40drd.co.in@outlook.office365.com/INBOX
DEBUG IMAP: IdleManager aborting IDLE for folder: imap://amith.bharathan%40drd.co.in@outlook.office365.com/INBOX
DONE
DEBUG IMAP: IdleManager adding imap://amith.bharathan%40drd.co.in@outlook.office365.com/INBOX to selector
DEBUG IMAP: IdleManager adding imap://amith.bharathan%40drd.co.in@outlook.office365.com/INBOX to selector
DEBUG IMAP: IdleManager waiting...
DEBUG IMAP: IdleManager selected 1 channels
DEBUG IMAP: IdleManager selected folder: imap://amith.bharathan%40drd.co.in@outlook.office365.com/INBOX
A10 OK IDLE completed.
DEBUG IMAP: handleIdle: set to RUNNING
DEBUG IMAP: waitIfIdle: wait done, idleState 0: Thread[pool-21-thread-2,5,main]
A11 FETCH 465 (ENVELOPE INTERNALDATE RFC822.SIZE)
DEBUG IMAP: IdleManager done watching folder imap://amith.bharathan%40drd.co.in@outlook.office365.com/INBOX
DEBUG IMAP: IdleManager waiting...
* 465 FETCH (ENVELOPE ("Wed, 29 Jun 2016 08:32:01 +0000" "test" (("Gopikrishnan V" NIL "gopikrishnan.v" "drd.co.in")) NIL NIL (("Amith K Bharathan" NIL "amith.bharathan" "drd.co.in")) NIL NIL NIL "<DB4PR06MB0464157DB21114B7E237B93C0230@DB4PR06MB046.eurprd06.prod.outlook.com>") INTERNALDATE "29-Jun-2016 14:02:05 +0530" RFC822.SIZE 18300)
A11 OK FETCH completed.
A12 FETCH 465 (BODYSTRUCTURE)
* 465 FETCH (BODYSTRUCTURE ("text" "html" ("charset" "iso-8859-1") NIL NIL "quoted-printable" 427 15 NIL NIL "en-GB" NIL))
A12 OK FETCH completed.
A13 FETCH 465 (BODY[TEXT]<0.427>)
* 465 FETCH (BODY[TEXT]<0> {427}
<html>
<head>
<meta http-equiv=3D"Content-Type" content=3D"text/html; charset=3Diso-8859-=
1">
<style type=3D"text/css" style=3D"display:none;"><!-- P {margin-top:0;margi=
n-bottom:0;} --></style>
</head>
<body dir=3D"ltr">
<div id=3D"divtagdefaultwrapper" style=3D"font-size:12pt;color:#000000;back=
ground-color:#FFFFFF;font-family:Calibri,Arial,Helvetica,sans-serif;">
<p>test<br>
</p>
</div>
</body>
</html>
FLAGS (\Seen \Recent))
A13 OK FETCH completed.
A14 FETCH 465 (BODY[TEXT]<0.427>)
* 465 FETCH (BODY[TEXT]<0> {427}
<html>
<head>
<meta http-equiv=3D"Content-Type" content=3D"text/html; charset=3Diso-8859-=
1">
<style type=3D"text/css" style=3D"display:none;"><!-- P {margin-top:0;margi=
n-bottom:0;} --></style>
</head>
<body dir=3D"ltr">
<div id=3D"divtagdefaultwrapper" style=3D"font-size:12pt;color:#000000;back=
ground-color:#FFFFFF;font-family:Calibri,Arial,Helvetica,sans-serif;">
<p>test<br>
</p>
</div>
</body>
</html>
FLAGS (\Seen \Recent))
A14 OK FETCH completed.
DEBUG IMAP: IdleManager watching imap://amith.bharathan%40drd.co.in@outlook.office365.com/INBOX
A15 IDLE
+ IDLE accepted, awaiting DONE command.
DEBUG IMAP: startIdle: set to IDLE
DEBUG IMAP: startIdle: return true
DEBUG IMAP: IdleManager.watch startIdle succeeded for imap://amith.bharathan%40drd.co.in@outlook.office365.com/INBOX
DEBUG IMAP: IdleManager selected 0 channels
DEBUG IMAP: IdleManager adding imap://amith.bharathan%40drd.co.in@outlook.office365.com/INBOX to selector
DEBUG IMAP: IdleManager waiting...
DEBUG IMAP: IdleManager selected 1 channels
DEBUG IMAP: IdleManager selected folder: imap://amith.bharathan%40drd.co.in@outlook.office365.com/INBOX
* 3 RECENT
* 466 EXISTS
DEBUG IMAP: waitIfIdle: request IdleManager to abort
DEBUG IMAP: waitIfIdle: wait to be not idle: Thread[pool-21-thread-2,5,main]
DEBUG IMAP: IdleManager continue watching folder imap://amith.bharathan%40drd.co.in@outlook.office365.com/INBOX
DEBUG IMAP: IdleManager aborting IDLE for folder: imap://amith.bharathan%40drd.co.in@outlook.office365.com/INBOX
DONE
DEBUG IMAP: IdleManager adding imap://amith.bharathan%40drd.co.in@outlook.office365.com/INBOX to selector
DEBUG IMAP: IdleManager adding imap://amith.bharathan%40drd.co.in@outlook.office365.com/INBOX to selector
DEBUG IMAP: IdleManager waiting...
DEBUG IMAP: IdleManager selected 1 channels
DEBUG IMAP: IdleManager selected folder: imap://amith.bharathan%40drd.co.in@outlook.office365.com/INBOX
A15 OK IDLE completed.
DEBUG IMAP: handleIdle: set to RUNNING
DEBUG IMAP: waitIfIdle: wait done, idleState 0: Thread[pool-21-thread-2,5,main]
A16 FETCH 466 (ENVELOPE INTERNALDATE RFC822.SIZE)
DEBUG IMAP: IdleManager done watching folder imap://amith.bharathan%40drd.co.in@outlook.office365.com/INBOX
DEBUG IMAP: IdleManager waiting...
* 466 FETCH (ENVELOPE ("Wed, 29 Jun 2016 08:35:56 +0000" NIL (("Gopikrishnan V" NIL "gopikrishnan.v" "drd.co.in")) NIL NIL (("Amith K Bharathan" NIL "amith.bharathan" "drd.co.in")) NIL NIL NIL "<DB4PR06MB0466336D31C8CE8919BD4B3C0230@DB4PR06MB046.eurprd06.prod.outlook.com>") INTERNALDATE "29-Jun-2016 14:05:57 +0530" RFC822.SIZE 11747)
A16 OK FETCH completed.
A17 FETCH 466 (BODYSTRUCTURE)
* 466 FETCH (BODYSTRUCTURE ("text" "html" ("charset" "iso-8859-1") NIL NIL "quoted-printable" 427 15 NIL NIL "en-GB" NIL))
A17 OK FETCH completed.
A18 FETCH 466 (BODY[TEXT]<0.427>)
* 466 FETCH (BODY[TEXT]<0> {427}
<html>
<head>
<meta http-equiv=3D"Content-Type" content=3D"text/html; charset=3Diso-8859-=
1">
<style type=3D"text/css" style=3D"display:none;"><!-- P {margin-top:0;margi=
n-bottom:0;} --></style>
</head>
<body dir=3D"ltr">
<div id=3D"divtagdefaultwrapper" style=3D"font-size:12pt;color:#000000;back=
ground-color:#FFFFFF;font-family:Calibri,Arial,Helvetica,sans-serif;">
<p>test<br>
</p>
</div>
</body>
</html>
FLAGS (\Seen \Recent))
A18 OK FETCH completed.
A19 FETCH 466 (BODY[TEXT]<0.427>)
* 466 FETCH (BODY[TEXT]<0> {427}
<html>
<head>
<meta http-equiv=3D"Content-Type" content=3D"text/html; charset=3Diso-8859-=
1">
<style type=3D"text/css" style=3D"display:none;"><!-- P {margin-top:0;margi=
n-bottom:0;} --></style>
</head>
<body dir=3D"ltr">
<div id=3D"divtagdefaultwrapper" style=3D"font-size:12pt;color:#000000;back=
ground-color:#FFFFFF;font-family:Calibri,Arial,Helvetica,sans-serif;">
<p>test<br>
</p>
</div>
</body>
</html>
FLAGS (\Seen \Recent))
A19 OK FETCH completed.
DEBUG IMAP: IdleManager watching imap://amith.bharathan%40drd.co.in@outlook.office365.com/INBOX
A20 IDLE
+ IDLE accepted, awaiting DONE command.
DEBUG IMAP: startIdle: set to IDLE
DEBUG IMAP: startIdle: return true
DEBUG IMAP: IdleManager.watch startIdle succeeded for imap://amith.bharathan%40drd.co.in@outlook.office365.com/INBOX
DEBUG IMAP: IdleManager selected 0 channels
DEBUG IMAP: IdleManager adding imap://amith.bharathan%40drd.co.in@outlook.office365.com/INBOX to selector
DEBUG IMAP: IdleManager waiting...
DEBUG IMAP: IdleManager selected 1 channels
DEBUG IMAP: IdleManager selected folder: imap://amith.bharathan%40drd.co.in@outlook.office365.com/INBOX
* 466 EXPUNGE
* 466 EXISTS
DEBUG IMAP: waitIfIdle: request IdleManager to abort
DEBUG IMAP: waitIfIdle: wait to be not idle: Thread[pool-21-thread-2,5,main]
DEBUG IMAP: IdleManager continue watching folder imap://amith.bharathan%40drd.co.in@outlook.office365.com/INBOX
DEBUG IMAP: IdleManager aborting IDLE for folder: imap://amith.bharathan%40drd.co.in@outlook.office365.com/INBOX
DONE
DEBUG IMAP: IdleManager adding imap://amith.bharathan%40drd.co.in@outlook.office365.com/INBOX to selector
DEBUG IMAP: IdleManager adding imap://amith.bharathan%40drd.co.in@outlook.office365.com/INBOX to selector
DEBUG IMAP: IdleManager waiting...
DEBUG IMAP: IdleManager selected 1 channels
DEBUG IMAP: IdleManager selected folder: imap://amith.bharathan%40drd.co.in@outlook.office365.com/INBOX
A20 OK IDLE completed.
DEBUG IMAP: handleIdle: set to RUNNING
DEBUG IMAP: waitIfIdle: wait done, idleState 0: Thread[pool-21-thread-2,5,main]
A21 FETCH 466 (ENVELOPE INTERNALDATE RFC822.SIZE)
DEBUG IMAP: IdleManager done watching folder imap://amith.bharathan%40drd.co.in@outlook.office365.com/INBOX
DEBUG IMAP: IdleManager waiting...
* 466 FETCH (ENVELOPE ("Wed, 29 Jun 2016 08:35:56 +0000" NIL (("Gopikrishnan V" NIL "gopikrishnan.v" "drd.co.in")) NIL NIL (("Amith K Bharathan" NIL "amith.bharathan" "drd.co.in")) NIL NIL NIL "<DB4PR06MB0466336D31C8CE8919BD4B3C0230@DB4PR06MB046.eurprd06.prod.outlook.com>") INTERNALDATE "29-Jun-2016 14:05:57 +0530" RFC822.SIZE 13152)
A21 OK FETCH completed.
A22 FETCH 466 (BODYSTRUCTURE)
* 466 FETCH (BODYSTRUCTURE ("text" "html" ("charset" "iso-8859-1") NIL NIL "quoted-printable" 427 15 NIL NIL "en-GB" NIL))
A22 OK FETCH completed.
A23 FETCH 466 (BODY[TEXT]<0.427>)
* 466 FETCH (BODY[TEXT]<0> {427}
<html>
<head>
<meta http-equiv=3D"Content-Type" content=3D"text/html; charset=3Diso-8859-=
1">
<style type=3D"text/css" style=3D"display:none;"><!-- P {margin-top:0;margi=
n-bottom:0;} --></style>
</head>
<body dir=3D"ltr">
<div id=3D"divtagdefaultwrapper" style=3D"font-size:12pt;color:#000000;back=
ground-color:#FFFFFF;font-family:Calibri,Arial,Helvetica,sans-serif;">
<p>test<br>
</p>
</div>
</body>
</html>
FLAGS (\Seen \Recent))
A23 OK FETCH completed.
A24 FETCH 466 (BODY[TEXT]<0.427>)
* 466 FETCH (BODY[TEXT]<0> {427}
<html>
<head>
<meta http-equiv=3D"Content-Type" content=3D"text/html; charset=3Diso-8859-=
1">
<style type=3D"text/css" style=3D"display:none;"><!-- P {margin-top:0;margi=
n-bottom:0;} --></style>
</head>
<body dir=3D"ltr">
<div id=3D"divtagdefaultwrapper" style=3D"font-size:12pt;color:#000000;back=
ground-color:#FFFFFF;font-family:Calibri,Arial,Helvetica,sans-serif;">
<p>test<br>
</p>
</div>
</body>
</html>
FLAGS (\Seen \Recent))
A24 OK FETCH completed.
DEBUG IMAP: IdleManager watching imap://amith.bharathan%40drd.co.in@outlook.office365.com/INBOX
A25 IDLE
+ IDLE accepted, awaiting DONE command.
DEBUG IMAP: startIdle: set to IDLE
DEBUG IMAP: startIdle: return true
DEBUG IMAP: IdleManager.watch startIdle succeeded for imap://amith.bharathan%40drd.co.in@outlook.office365.com/INBOX
DEBUG IMAP: IdleManager selected 0 channels
DEBUG IMAP: IdleManager adding imap://amith.bharathan%40drd.co.in@outlook.office365.com/INBOX to selector
DEBUG IMAP: IdleManager waiting...
主体“test”的电子邮件正在重复
请建议。
由于
Amith
答案 0 :(得分:1)
这是邮箱中的邮件号码466。服务器宣布新消息:
* 3 RECENT
* 466 EXISTS
您处理消息:
A16 FETCH 466 (ENVELOPE INTERNALDATE RFC822.SIZE)
...
您等待新消息,服务器会告诉您:
* 466 EXPUNGE
* 466 EXISTS
这意味着邮箱号码466已完全从邮箱中删除,邮箱中有一条新邮件号码466。 JavaMail会通知您新的消息号466.显然,它与删除的消息号466完全相同。
我不知道为什么服务器会这样做。对我来说,它看起来像服务器中的一个错误。 请向Microsoft报告。
您可能需要查看正在处理的邮件的IMAP UID。新消息466绝对必须具有不同的UID。如果没有,那就是服务器中的一个更严重的错误。
您还可以查看邮件的Message-ID,以确保之前没有看到该邮件。如果所有错误情况都是这样,您可能只需要保留一条消息的历史记录。但请注意,虽然Message-ID是唯一的,并且通常是唯一的,但与IMAP UID不同,不能保证它们 唯一,甚至根本不存在。