我正在使用优秀的inbox node.js库,对于某些电子邮件帐户,我没有看到某些默认邮箱,例如“已发送邮件”。我几乎使用OAUTH2的示例代码;
client = inbox.createConnection(false, "imap.gmail.com", {
secureConnection: true,
auth: {
XOAuth2: {
user: account.email,
clientId: Settings.googleApp.clientId,
clientSecret: Settings.googleApp.secretId,
refreshToken: refreshToken,
accessToken: accessToken,
timeout: expires
}
}
});
client.connect();
client.on("connect", function() {
Logger.debug("Opening mailbox " + mailbox);
self.getMailboxes(function(err, boxes){
var boxNames = _.pluck(boxes, 'name');
Logger.info(boxNames);
});
}
我有点难过......
答案 0 :(得分:0)
谢谢,所以我最终使用了类型(type ='Sent')并遍历所有子邮箱以提取所有已发送邮箱,这允许邮箱的区域设置特定名称。这是代码;
client.listMailboxes(function(error, mailboxes){
var _findSent = function(mailbox, callback){
if(mailbox.hasChildren){
mailbox.listChildren(function(error, children){
var sent = [];
for(var i=0; i < children.length; i++){
if (children[i].type == 'Sent'){
sent.push(children[i]);
}
}
callback(null, sent);
});
}
else {
var sent = [];
if (mailbox.type == 'Sent'){
sent.push(mailbox);
}
callback(null, sent);
}
}
async.map(mailboxes, _findSent, function(err, results){
onGotSentMailboxes(_.flatten(results));
});
});