我试图弄清楚IMAP到Gmail帐户的状态。
var Imap = require('imap');
var imapConnection = new Imap({
username: '',
password: '',
host: "imap.gmail.com",
port: 993,
debug: console.log
});
function testemail(){
imapConnection.connect();
if(imapConnection.state == 'authenticated'){
console.log('yay authenticated')
}
else{
console.log('No success:'+imapConnection.state)
}
}
**Output display:**
No success:disconnected
․[connection] Connected to host
我很困惑,为什么它说它已连接到主机,而当我打印IMAP的状态时却说“已断开”?